Forum Moderators: coopster
Here is my php code:
<?php
session_start();
//include our db data to make the connection
include ('db.php');
$selector = $_GET['selector'];
$sorter = $_GET['sorter'];
//pull all the data from users table
$content = mysql_query("SELECT order_id, user_id, ingredients, price, quantity, Day, Date, Month, Year, Time FROM orders ORDER BY '$selector' '$sorter'");
while($row = mysql_fetch_array($content))
{
echo
$row['order_id'].' '.
$row['user_id'].' '.
$row['ingredients'].' '.
$row['price'].' '.
$row['quantity'].' '.
$row['Day'].' '.
$row['Date'].' '.
$row['Month'].' '.
$row['Year'].' '.
$row['Time'].'<br />';
}
?>
and here is the form:
<p>Sort according to:</p>
<form action="stats.php" method="GET">
<select name="selector">
<option>Selector</option>
<option value="Month">Month</option>
<option value="Year">Year</option>
<option value="nick">Nick</option>
<option value="order_id">Order ID</option>
</select>
<input type="submit" value="OK" /><br />
<select name="sorter">
<option>Sorter</option>
<option value="DESC">DESC</option>
<option value="ASC">ASC</option>
</select>
</form>