-
I’m trying to pull data from 2 tables and when I add this in the $query, the results are all messed up when I click my link ex. /leads.php?contactstatus=Hot
-
How can I by default display all contactstatus types when I only have “Hot” “Warm” “Cold” as options in the table row contactstatus?
<? mysql_connect ("xxxx","xxxx","xxxx") or die ('Error: ' .mysql_error()); mysql_select_db ("xxxx"); if(isset($_GET['contactstatus']) && in_array($_GET['contactstatus'], array('Hot', 'Warm', 'Cold'))){ $status = $_GET['contactstatus']; } else { $status = ''; // what do I put here so by default users for all contactstatus types show in results } $query = "SELECT * FROM contacts,contacttodo WHERE contacts.contactstatus = `'".$status."' OR contacttodo.type = 'Appointment'";` $result=mysql_query($query); while($row = mysql_fetch_array($result)){ ?>
UPDATE:
This works:
<div class="nav">
<table width="100%">
<tr>
<td>
<li><a href="/dbs/a.php?type=Appointment">Appointments</a></li>
<li><a href="/dbs/a.php?contactstatus=Hot">Hot</a></li>
<li><a href="/dbs/a.php?contactstatus=Warm">Warm</a></li>
<li><a href="/dbs/a.php?contactstatus=Cold">Cold</a></li>
</td>
</tr>
</table>
</div>
$status = '';
$todotype = '';
if(isset($_GET['contactstatus'])
&& in_array($_GET['contactstatus'], array('Hot', 'Warm', 'Cold')))
{
$status = $_GET['contactstatus'];
$query = "SELECT * FROM contacts,contacttodo,contactnotes WHERE contacts.ID = contacttodo.contacts_id = contactnotes.contacts_id AND contacts.contactstatus = '".$status."' ORDER BY contacts.firstname ASC";
}
if(isset($_GET['type'])
&& in_array($_GET['type'], array('Appointment', 'Email', 'Call')))
{
$todotype = $_GET['type'];
$query = "SELECT * FROM contacts,contacttodo,contactnotes WHERE contacts.ID = contacttodo.contacts_id = contactnotes.contacts_id AND contacttodo.type = '".$todotype."' ORDER BY contacts.firstname ASC";
}
$result=mysql_query($query);
while ($row = mysql_fetch_array($result)) {
<div id="contact-results">
<table width="100%" cellspacing="0" cellpadding="0" class="contact-results">
<tr>
<td align="left" width="15%"><a href="/dbs/editcontact.php?ID=<? echo $row['ID']; ?>"><strong><? echo $row['firstname']; ?> <? echo $row['lastname']; ?></strong></a></td>
<td align="left" width="5%"><? echo $row['contactstatus']; ?></td>
<td align="left" width="15%"><? echo $row['contacttype']; ?></td>
</tr>
</table>
</div>
<?
}
mysql_close();
?>
By default how can I display all ‘Hot’ ‘Warm’ ‘Cold’ leads?
try
The contacttodo.id = contacts.id need to be updated for your structure