set default based on several criteria
These links give me results for each when clicked, however how do I get 'All' to display all the 'Hot' 'Warm' and 'Cold' leads because 'All' is the default page?
<li><a href="/dbs/a.php?contactstatus=">All</a></li>
<li><a hre开发者_StackOverflowf="/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>
if(isset($_GET['contactstatus'])
&& in_array($_GET['contactstatus'], array('Hot', 'Warm', 'Cold')))
{
$status = $_GET['contactstatus'];
$query = "SELECT * FROM contacts WHERE contactstatus = '".$status."' ORDER BY contacts.firstname ASC";
}
if(isset($_GET['type'])
&& in_array($_GET['type'], array('Appointment')))
{
$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";
}
UPDATE:
Got this to work by adding:
$query = "SELECT * FROM contacts WHERE contactstatus = 'Hot' OR contactstatus = 'Warm' OR contactstatus = 'Cold' ORDER BY contacts.contacttype ASC";
However, is this safe?
It's certainly 'safe', as long as you're never going to have any other contact statuses besides hot, warm, or cold.
精彩评论