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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.