Post Description: how to count number of rows in a mysql query get total count rows
This Post Has Been Viewed 381 Times Since Fri Feb 29, 2008 12:01 pm Posted By web hosting with 1 replies
POST# 568
Posted On: Fri Feb 29, 2008 12:01 pm
lets say you want to get the total number of queries in a mysql database.
for example, i have a forums and i want to know how many replies the topic number 455 has recieved, i can use this:
$sql = "SELECT COUNT(reply) WHERE topic='455'"
$row = mysql_fetch_row($result);
$count = $row[0];
TEMPLATE:
$sql = "SELECT COUNT (field) WHERE field='$velue'"
$result = mysql_query($sql ,$db);
$row = mysql_fetch_row($result);
$count = $row[0];
Mon Feb 18, 2008 9:23 pm
1
hostman
Reply #1181
this is anoter one i use
$db = mysql_connect("HOSTNAME", "USERNAME", "PASSWORD");
mysql_select_db("DATABASE_NAME",$db);
$sql2 = "select count(id) from ".$db_prefix."wallpaper WHERE status = '".$_GET['show']."'";
$result2 = mysql_query($sql2 ,$db);
$row2 = mysql_fetch_row($result2);
$num_of_items = $row2[0];
$start_reply = ($page_num * $replies_per_page);
$total_pages = ceil($reply_numbs/$items_per_page);