How To Count Number Of Rows In A Mysql Query Get Total Count Rows
how to count number of rows in a mysql query get total count rows
how, to, count, number, of, rows, in, a, mysql, query, get, total, count, rows
How To Count Number Of Rows In A Mysql Query Get Total Count Rows
Post Description: how to count number of rows in a mysql query get total count rows
POST# 568
Posted On: Fri Feb 29, 2008 12:01 pm
web hosting
Topic: How To Count Number Of Rows In A Mysql Query Get Total Count Rows
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);

What do you think?

* name:  

* email:  

* Please enter comments:


Receive Replies on my Comments
(An email will be sent to you when someone replies to your comments)

Add image to comments
yes no             upload