Is there not a way that a person could do one or two read instructions and obtain all the records in the different categories in one go?
certainly
select category
, count(*) as test from offers group
by category
Rewriting your original PHP with rudy's SQL:
<?php
include("includes/dbdetail.inc.php"); mysql_connect("$servname","$servuser","$servpass"); mysql_select_db("$dbname");
$get_cat_counts = 'select category, count(*) as test from offers group by category';
$result = mysql_query($get_cat_counts); while ($row = mysql_fetch_array($result)){ $count = $row['test']; $category = $row['category']; echo '<td class="books" width="5%" height="20"> '; echo "<font color=#FF0000><b>$category: $count</b></font>"; echo '</td>'; }
?>
One thing this does is remove the repeated calls to connect to MySQL. If you had 16 before there will now be just one. There is quite a bit of overhead involved in establishing a connection so that alone will help.
I don't know what's in dbdetail.inc.php so I'm not sure it's in the right place. Also I've added an echo of the category name followed by the count for that category.
Sheila
____ • The WDVL Discussion List from WDVL.COM • ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED]
To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email.
To change subscription settings to the wdvltalk digest version:
http://wdvl.internet.com/WDVL/Forum/#sub
________________ http://www.wdvl.com _______________________
You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED]
To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016
Please include the email address which you have been contacted with.