What would I need to add so that I can return a count of the number of rows retrieved in the query? I am not sure where to include the COUNT (another query?) and then what syntax to use to print the result. thanks

$data = mysql_query('SELECT * FROM `bus_basic` ORDER BY `name` ASC ')
or die(mysql_error());

Print "<table cellpadding=3>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "".$info['name'] . " ";
Print "<br>&nbsp;&nbsp;&nbsp;".$info['address'] . " ";
Print "<br>&nbsp;&nbsp;&nbsp;".$info['city'] . ", ";
Print "".$info['state'] . "&nbsp;&nbsp;";
Print "".$info['zip'] . " ";
Print "<br>&nbsp;&nbsp;&nbsp;".$info['phone'] . " ";
Print "<br><b>Main Category:</b> ".$info['cat1'] . " ";
Print "<br>&nbsp;&nbsp;&nbsp;<b>Sub Category:</b> ".$info['subcat1'] . " ";
Print "<br>&nbsp;&nbsp;&nbsp;<b>Sub Category:</b> ".$info['subcat2'] . " <br><hr> </td></tr>";
}
Print "</table>";

Oh, some details:
server is running php4
mysql version 5
I use dreamweaver and phpmyadmin.

i hope that helps

Here is your MySQL tutorial

A common way to do it is this:

$data = mysql_query('SELECT * FROM `bus_basic` ORDER BY `name` ASC ')
or die(mysql_error());

Print "<table cellpadding=3>";
$count = 0;
while($info = mysql_fetch_array( $data ))
{
$count++;
Print "<tr>";
Print "".$info['name'] . " ";
Print "<br>&nbsp;&nbsp;&nbsp;".$info['address'] . " ";
Print "<br>&nbsp;&nbsp;&nbsp;".$info['city'] . ", ";
Print "".$info['state'] . "&nbsp;&nbsp;";
Print "".$info['zip'] . " ";
Print "<br>&nbsp;&nbsp;&nbsp;".$info['phone'] . " ";
Print "<br><b>Main Category:</b> ".$info['cat1'] . " ";
Print "<br>&nbsp;&nbsp;&nbsp;<b>Sub Category:</b> ".$info['subcat1'] . " ";
Print "<br>&nbsp;&nbsp;&nbsp;<b>Sub Category:</b> ".$info['subcat2'] . " <br><hr> </td></tr>";
}
Print "</table>";

You can echo $count within your while loop (eg. for row numbers) or after the loop (for total rows).


Matti Ressler
Suomedia

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.