kendallkamikaze Posted April 6, 2009 Share Posted April 6, 2009 Title kind of explains it. This code below is functional, the issue is that I need it to just display the number of rows, and not all the rows. <?php $horseid=$_GET['id']; $query = mysql_query("SELECT * FROM class_event_entered WHERE horseid='$horseid'"); $number=mysql_num_rows($query); while($r=mysql_fetch_array($query)) { $horseid=$r["horseid"]; print "<font size='3pt' face='comic sans ms'>Show Entries - #$horseid is entered in $number shows.</font> <br> "; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/152750-solved-counting-table-rows-but-just-displaying-number-not-all-rows/ Share on other sites More sharing options...
Yesideez Posted April 6, 2009 Share Posted April 6, 2009 I see no problems with that script but unsure of what you're asking. If you don't want to show all the rows you'll need a different query... Quote Link to comment https://forums.phpfreaks.com/topic/152750-solved-counting-table-rows-but-just-displaying-number-not-all-rows/#findComment-802122 Share on other sites More sharing options...
kendallkamikaze Posted April 6, 2009 Author Share Posted April 6, 2009 I just want it to say a numeral like 'this horse is entered in X number of shows.' the way it is now, it lists the same thing over and over. Quote Link to comment https://forums.phpfreaks.com/topic/152750-solved-counting-table-rows-but-just-displaying-number-not-all-rows/#findComment-802123 Share on other sites More sharing options...
Yesideez Posted April 6, 2009 Share Posted April 6, 2009 Sorry, I'm at work answering between jobs here... Is this what you're after? <?php $horseid=$_GET['id']; $query = mysql_query("SELECT COUNT(*) AS numentered FROM class_event_entered WHERE horseid='$horseid'"); $r=mysql_fetch_assoc($query); print "<font size='3pt' face='comic sans ms'>Show Entries - #$horseid is entered in ".$r['numentered']." shows.</font> <br> "; ?> Quote Link to comment https://forums.phpfreaks.com/topic/152750-solved-counting-table-rows-but-just-displaying-number-not-all-rows/#findComment-802177 Share on other sites More sharing options...
sasa Posted April 6, 2009 Share Posted April 6, 2009 or <?php $horseid=$_GET['id']; $query = mysql_query("SELECT * FROM class_event_entered WHERE horseid='$horseid'"); $number=mysql_num_rows($query); print "<font size='3pt' face='comic sans ms'>Show Entries - #$horseid is entered in $number shows.</font> <br> "; ?> Quote Link to comment https://forums.phpfreaks.com/topic/152750-solved-counting-table-rows-but-just-displaying-number-not-all-rows/#findComment-802289 Share on other sites More sharing options...
kendallkamikaze Posted April 6, 2009 Author Share Posted April 6, 2009 or <?php $horseid=$_GET['id']; $query = mysql_query("SELECT * FROM class_event_entered WHERE horseid='$horseid'"); $number=mysql_num_rows($query); print "<font size='3pt' face='comic sans ms'>Show Entries - #$horseid is entered in $number shows.</font> <br> "; ?> This is what I was looking for. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/152750-solved-counting-table-rows-but-just-displaying-number-not-all-rows/#findComment-802603 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.