rendered paste body<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Contacts</title><link href="datum.css" rel="stylesheet" type="text/css"></head><body><?php$order_by = $_GET['order_by'];if (empty($order_by)) {$order_by='last_name';};$direction = $_GET['direction'];if (empty($direction)) {$direction='ASC';};$limit = 300;$action = $_REQUEST['action'];$color1 = "#F5F9FE";$color2 = "#ECF1FD";$title[0] = 'first_name';$title[1] = 'last_name';$title[2] = 'a.name';$title[3] = 'email1';$i = 0;while ($i <= 3) { $value[$i] = ''; $i++; }if ($action != 'Clear') { $value[0] = $_POST['search_first_name']; $value[1] = $_POST['search_last_name']; $value[2] = $_POST['search_account_name']; $value[3] = $_POST['search_email']; }?> <div id="container800"><table width="400" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F9F9F9"> <tr> <td class="header2"><div align="center"><a href="accounts.php">ACCOUNTS</a></div></td> <td class="header2"><div align="center"><a href="contacts.php">CONTACTS</a></div></td> <td class="header2"><div align="center"><a href="quotes.php">QUOTES</a></div></td> </tr></table><br><br><div id="container700"><form name="form1" method="post" action="<?php echo "$PHP_SELF"; ?>"> <table width="100%" border="0" cellpadding="2" cellspacing="0" bgcolor="#F9F9F9"> <tr><td colspan=4><div class=header3a>Search Contacts:</div></td></tr> <tr> <td width="20%" class="table_label">First Name: </td> <td width="30%" class="table_text"><input type="text" name="search_first_name" tabindex="1" value="<?php echo $value[0]; ?>"></td> <td width="20%" class="table_label">Account Name: </td> <td width="30%" class="table_text"><input type="text" name="search_account_name" tabindex="3" value="<?php echo $value[2]; ?>"></td> </tr> <tr> <td class="nobrd_table_label">Last Name: </td> <td class="nobrd_table_text"><input type="text" name="search_last_name" tabindex="2" value="<?php echo $value[1]; ?>"></td> <td class="nobrd_table_label">E-Mail:</td> <td class="nobrd_table_text"><input type="text" name="search_email" tabindex="4" value="<?php echo $value[3]; ?>"></td> </tr> </table> <div id="edit_buttons"> <input name="action" value="Clear" type="submit" tabindex="6"/> <input name="action" value="Search" type="submit" tabindex="5"/> </div></form></div><br><br><?php// DOES SEARCHif ($action == "Search") { $search = ''; $first = 'true'; $i=0; while($i <= 3) { if(!empty($value[$i])) { if($first != 'true' ) {$search = $search." AND ";} $search2 = $title[$i]." LIKE '%".$value[$i]."%'"; $search = $search." ".$search2; $first = 'false'; } $i++; } if(!empty($search)) { //echo "<div class=notice2><span class=stdtxt>$search</span></div><br>"; $query="SELECT c.*, a.name AS account_name FROM contacts c LEFT JOIN accounts a ON c.account_id=a.id WHERE $search ORDER BY $order_by"; } else { $query="SELECT c.*, a.name AS account_name FROM contacts c LEFT JOIN accounts a ON c.account_id=a.id ORDER BY $order_by"; } }else { $query="SELECT c.*, a.name AS account_name FROM contacts c LEFT JOIN accounts a ON c.account_id=a.id ORDER BY $order_by"; }// prints start of tableecho " <table width=100% bgcolor=#F9F9F9 align=center border=0 cellpadding=2 cellspacing=0> <tr><td colspan=4><div class=header3a>Contacts:</div></td></tr> <tr bgcolor=$color1> <td width=20% class=list_title><a href=contacts.php?order_by=last_name><b>Name</b></a></td> <td width=27% class=list_title><a href=contacts.php?order_by=account_id><b>Account Name</b></a></td> <td width=32% class=list_title><a href=contacts.php?order_by=email1><b>E-Mail</b></a></td> <td width=21% class=list_title><a href=contacts.php?order_by=phone_work><b>Office #</b></a></td> </tr>";// form the query for selecting all contactsinclude("inc/db_connect.php");$result=mysql_query($query) or die(mysql_error());mysql_close();// set up loop variables and do$i=0;while ($row = mysql_fetch_assoc($result)) { $id = $row['id']; $first_name = $row['first_name']; $last_name = $row['last_name']; $account_id = $row['account_id']; $account_name = $row['account_name']; $email1 = $row['email1']; $phone_work = $row['phone_work']; $full_name = $first_name.' '.$last_name; $row_color = ($i % 2) ? $color1 : $color2; echo " <tr bgcolor=$row_color> <td class=list_item><a href=contact_details.php?contact_id=$id>$full_name</a></td> <td class=list_item><a href=account_details.php?account_id=$account_id>$account_name</a></td> <td class=list_item><a href=mailto:$email1>$email1</a></td> <td class=list_item>$phone_work</td> </tr>"; $i++; }// ends tableecho "</table></span>";?></div></body></html>