big-dog1965 Posted December 29, 2007 Share Posted December 29, 2007 Can someone help with this I want to find how many of each differant fields are associated with another field I dont really know how to explain it so heres a link p.htm to show what is happening with the 1st portion of code On the linked page I show what I need it to look like. the second portion of code below is what I was trying to make work to accomlish it but dont know how or even if its the way to do it.. mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); mysql_query($query); $query = "SELECT Attend_Round, COUNT(Monster_Truck) FROM Entry_Form GROUP BY Attend_Round"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo $row['Attend_Round'] ." ". $row['COUNT(Monster_Truck)'] ." items."; echo "<br />"; } ?> $result=mysql_query($query); $num=mysql_numrows($result); if ($num==0) { echo ""; }else{ echo ""; } mysql_close(); $i=0; while ($i < $num) { $Attend_Round=mysql_result($result,$i,"Attend_Round"); $Eighth_Scale_Buggy=mysql_result($result,$i,"Eighth_Scale_Buggy"); $Eighth_Scale_Sportsman=mysql_result($result,$i,"Eighth_Scale_Sportsman"); $Arena_Truck=mysql_result($result,$i,"Arena_Truck"); $Monster_Truck=mysql_result($result,$i,"Monster_Truck"); $Stadium_Truck=mysql_result($result,$i,"Stadium_Truck"); echo "<b>$[b][/b]Attend_Round<br>$Eighth_Scale_Buggy<br>$Eighth_Scale_Sportsman<br>$Arena_Truck<br>$Monster_Truck<br>$Stadium_Truck<hr>"; $i++; } ?> Link to comment https://forums.phpfreaks.com/topic/83644-pulling-information-from-mysql-and-displaying-on-web-page/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.