Here is my current code for the drop down and search box...
Code: Select all
<!--begin order-->
<form name="order">
<font face="verdana" size="2">Sort By </font>
<select size="1" name="category" style="font-family: Verdana; font-size: 8pt; border-style: solid; border-width: 1; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1" onChange="location=document.order.category.optionsїdocument.order.category.selectedIndex].value;" value="GO">
<option>---------------</option>
<option value="?id=results2&search=<?=$_POSTї'search']?>&order=date&how=desc">Date (DESC)</option>
<option value="?id=results2&search=<?=$_POSTї'search']?>&order=date&how=asc">Date (ASC)</option>
<option value="?id=results2&search=<?=$_POSTї'search']?>&order=name&how=asc">Title (ASC)</option>
<option value="?id=results2&search=<?=$_POSTї'search']?>&order=name&how=desc">Title (DESC)</option>
<option value="?id=results2&search=<?=$_POSTї'search']?>&order=category&how=asc">Category (ASC)</option>
<option value="?id=results2&search=<?=$_POSTї'search']?>&order=category&how=desc">Category (DESC)</option>
</select>
</form>
<!--end order-->
</td>
<td align="left" width="408">
<!--begin search-->
<FORM METHOD="post" ACTION="http://localhost/george/articles/index.php">
<font size="2" face="Verdana">
<input type="submit" value="Title Search" name="Title Search" style="font-size: 7pt; font-family: Verdana; border-style: solid; border-width: 1"> </font>
<input type="text" name="search" size="30" style="font-family: Verdana; font-size: 8pt; border-style: solid; border-width: 1">
</form>
<!--end search-->Code: Select all
<?php include('../georgedb.php');?>
<center><table border="0" cellspacing="1">
<tr>
<td width="10"></td>
<td width="100"><b><font face="Verdana" size="2">Date</font></b></td>
<td width="315"><b>
<font face="Verdana" size="2">Title</font></b></td>
<td width="163"><b><font face="Verdana" size="2">Category</font></b></td>
</tr>
<?
if (!$order){
$order = 'date';
}
if (!$how){
$how = 'desc';
}
$sqlquery = "SELECT * FROM articles WHERE name LIKE '%$search%' ORDER BY $order $how";
$result = mysql_query($sqlquery);
$number = mysql_numrows($result);
$i = 0;
if ($number < 1) {
print '<font face="verdana" size="2"><b>
Sorry, there are no queries that match your search.<p> </p></b></font>';
}
else {
while($data = mysql_fetch_assoc($result)) {
?>
<tr>
<td width="10"></td>
<td width="100"><font face="verdana" size="2"><?=$dataї"date"];?></font></td>
<td width="315"><font face="verdana" size="2"><a href="<?=$dataї'link'];?>" style="color:#000000"><?=$dataї'name'];?></a></font></td>
<td width="163"><font face="verdana" size="2"><a href="<?=$dataї'catlink'];?>" style="color:#000000"><?=$dataї'category'];?></a></font></td>
</tr>
<?php
}
}
?>
</table></center>*F.Y.I. - I'm running Windows XP, Apache 1.3.22, PHP 4.1.0, and MySQL 3.23.39