Jump to content

[SOLVED] counting table rows but just displaying number, not all rows


kendallkamikaze

Recommended Posts

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>
";
}
?>

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>
";
?>

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>
";
?>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.