This simple query is proving to be a problem for me as I'm missing something obvious.
Its a query to show Sales by Market ($var2) by Month ($var1).
Any pointers as to what I'm doing wrong.
<html>
<head><title>Monthly Sales Rank </title>
<LINK REL=StyleSheet HREF="style.css" TYPE="text/css" MEDIA=screen>
<script src="sorttable.js"></script>
</head>
<body>
Select Month:<br />
<select name="Var1">
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
<option value="January">January</option>
</select>:<br />
Select Market:<br />
<select name="Var2">
<option value="Good">Good</option>
<option value="Bad">Bad</option>
<option value="Ugly">Ugly</option>
</select>:<br />
<?php
set_time_limit(0);
error_reporting (E_ALL ^ E_NOTICE);
include 'db.php';
$Mnth = $_POST["Var1"];
$Mkt = $_POST["Var2"];
$result = mysql_query('
Select
MonthName(OrderDate),
Sum(OrderedQuantity) As Ordered,
Round(Avg(Price),2) As AvgSellPrice,
Round(Avg(Shipping),2) As AvgShipping,
MarketName
From Mydb
where MonthName(OrderDate) = "$Mnth" and Market = "$Mkt"
Group By Market, MonthName(OrderDate)
with rollup
')
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "Click on column name to sort. Totals now showing. More options at end <P>";
print "<table class='sortable' width=800 border=1>\n";
echo "<tr> <th>Title</th> <th>Ord Qty</th> <th>Avg Sales Rank</th> <th>£ Min</th> <th>£ Max</th> <th>£ Average</th> <th>Market</th> </tr>";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><font face=arial size=2/>$field</font></td>\n";
print "</tr>\n";
}
print "</table>\n";
?>
</body>
</html>