Borderline Posted October 23, 2009 Report Share Posted October 23, 2009 (edited) I have a mini racing system, and I'd like to run several filters on the data to gauge where the more profitable areas are (if they exist!) I thought I might be able to use php/mysql to query the data - I thought that the profit/loss number of winners would be automatically updated each time I upload more data.My code currently looks like this: <?php // Make a MySQL Connection mysql_connect("*****", "*****", "*****") or die(mysql_error()); mysql_select_db("******") or die(mysql_error());?> <table border="1" cellpadding="2" cellspacing="0" width="100%"> <tr> <td width="25%">No Filter</td> <td width="25%"><?php $query = "SELECT SUM(profit) FROM *****"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo $row['SUM(profit)']; echo "<br />"; } ?></td> <td width="25%"><?php $query = "SELECT COUNT(horse) FROM ***** WHERE pos ='1'"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "Number of winners:". $row['COUNT(horse)'] ." ". $row['type'] .""; echo "<br />"; } ?></td> <td width="25%"><?php $query = "SELECT COUNT(horse) FROM *****"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "Number of qualifers:". $row['COUNT(horse)'] ." ". $row['type'] .""; echo "<br />";}?></td> </tr></table> The plan is to have 30+ different filters for this data - can you see a suitable method for displaying this as a single table, or will I have to repeat the above code 30ish times? Any advice appreciated, as always! Edited October 23, 2009 by Borderline Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now