So I’m trying to get data from my sql database and sort it by certain variables that are related to some report generations that I might want to make.
<?
$sql = 'SELECT DISTINCT jsfdName.baseData AS Name, jsfdAddr.baseData as Address, jsfdZip.baseData AS Zip, jsfdCity.baseData AS City, jsfdState.baseData AS State,jsfdPhone.baseData AS Phone, jsfdPerson.baseData AS Person, jsfdContacted.baseData AS Contacted
FROM jos_sobipro_field_data AS jsfdName
JOIN jos_sobipro_field_data AS jsfdAddr USING(sid)
JOIN jos_sobipro_field_data AS jsfdZip USING(sid)
JOIN jos_sobipro_field_data AS jsfdCity USING(sid)
JOIN jos_sobipro_field_data AS jsfdState USING(sid)
JOIN jos_sobipro_field_data AS jsfdPhone USING(sid)
JOIN jos_sobipro_field_data AS jsfdPerson USING(sid)
JOIN jos_sobipro_field_data AS jsfdContacted USING(sid)
WHERE jsfdName.fid = 36 AND jsfdAddr.fid = 37 AND jsfdZip.fid=38 AND jsfdCity.fid = 39 AND jsfdState.fid = 41 AND jsfdPhone.fid = 46 AND jsfdPerson.fid = 62 AND jsfdContacted.fid = 61 AND sid > 905';
$rs_result = mysql_query($sql) or die (mysql_error());
$ttl=mysql_num_rows($rs_result);
?>
<center><H2><?=$sitename;?></h2>
<h3>Business Information</h3></center>
<center>Total Entries in Report: <?=$ttl;?></center>
<table border="1" ALIGN = CENTER>
<tr><th>Name</th><th>Address</th><th>Zip</th><th>City</th><th>State</th><th>Phone</th><th>Sales Person</th><th>Contact Method</th></tr>
<?
while ($row = mysql_fetch_assoc($rs_result)) {
?>
<tr>
<td><? echo $row[Name]; ?></td>
<td><? echo $row[Address]; ?></td>
<td><? echo $row[Zip]; ?></td>
<td><? echo $row[City]; ?></td>
<td><? echo $row[State]; ?></td>
<td><? echo $row[Phone]; ?></td>
<td><? echo $row[Person]; ?></td>
<td><? echo $row[Contacted]; ?></td>
</tr>
<? }; ?></table>
So I was looking to only display the Sales People whose name is Justin, Jeremy, etc. So I was thinking I would have to add another condition to my where clause that said something like AND Person = “Justin”….. But that doesn’t work. Any ideas?
Thanks for the help
I added another AND at the end of my WHERE clause. It couldn’t be before the end or else it effected the table and gave me errors. So Now the where clause looks like this…
Thanks again guys