Hello all.
This is a bit of code that I had help with here, and now it is working, but I want to also sort the results of 'admin.php?view=all' by id, sku, or stock status. Right now, the results are sorted by the above only when the view includes &sview=$sview'. In other words, how do I print different links if the selected view is "all"? I can then just get rid of the &sview stuff, and it will work. Hopefully this is making any sense at all.
$query = "select DISTINCT manufacturer from product_status ORDER BY manufacturer ASC";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
for ($i=-0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
$myvarm = $row["manufacturer"];
echo "<font face='Verdana' size='2'><a href='admin.php?sview=$myvarm'>$myvarm";
echo"</a>";
echo " | ";
}
print "<br><p align='center'><font face='Verdana' size='2'><a href='admin.php?view=all'><b>View All</b></a></p>";
print "<font face='Verdana' size='1'>SORT BY: (<b>not working yet with 'View All' except manufacturer link)</b> <br><br>";
print "<a href='admin.php?view=id&sview=$sview'>Product ID</a> | <a href='admin.php?view=manufacturer'>Manufacturer</a> | <a href='admin.php?view=sku&sview=$sview'>SKU</a> | <a href='admin.php?view=status&sview=$sview'>Stock Status</a></font><br><br><div align='right'><font face='Verdana' size='2'><a href='admin.php?action=add&comment=1'>Add A Product</a> | <a href='admin.php?action=addm'>Add A Manufacturer</a> <br><br>";
if (isset($view) and ($view == "id")) {
$query = "SELECT product_id,manufacturer,product_name,product_price,product_sku,shipping,stock_status,stock_comment FROM product_status WHERE manufacturer='$sview' ORDER BY product_id ASC";
}else if (isset($view) and ($view == "manufacturer")) {
$query = "SELECT product_id,manufacturer,product_name,product_price,product_sku,shipping,stock_status,stock_comment FROM product_status ORDER BY manufacturer ASC";
}else if (isset($view) and ($view == "sku")) {
$query = "SELECT product_id,manufacturer,product_name,product_price,product_sku,shipping,stock_status,stock_comment FROM product_status WHERE manufacturer='$sview' ORDER BY product_sku ASC";
}else if (isset($view) and ($view == "status")) {
$query = "SELECT product_id,manufacturer,product_name,product_price,product_sku,shipping,stock_status,stock_comment FROM product_status WHERE manufacturer='$sview' ORDER BY stock_status ASC";
}else if (isset($view) and ($view == "all")) {
$query = "SELECT product_id,manufacturer,product_name,product_price,product_sku,shipping,stock_status,stock_comment FROM product_status ORDER BY product_id ASC";
}else{
$query = "SELECT product_id,manufacturer,product_name,product_price,product_sku,shipping,stock_status,stock_comment FROM product_status WHERE manufacturer='$sview' ORDER BY product_id ASC";
}
$result = mysql_query($query) or die("Query failed really bad");
print "<table border='1' cellpadding='3' cellspacing='0'>\n";
print "<tr bgcolor='#000066'>";
yadda yadda yadda more results.
Thanks in advance.