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
 (381) dminister a web business
How To Count Number Of Rows In A Mysql Query Get Total Count Rows
Post Description:
Post Tags: how, to, count, number, of, rows, in, a, mysql, query, get, total, count, rows
This Post Has Been Viewed 772 Times Since Mon Feb 18, 2008 9:04 pm Posted By hostman with 1 replies
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];



Leave Your Comments     [ dejar commentarios ]
  * Name     [nombre]

  * eMail (will not be published)     [coreo electronico]

* Enter Your Reply or Comments:    [commentarios]


Add Picture To Comments         [incluir foto]
YES NO             upload
Receive Replies on my Comments (An email will be sent to you when someone replies to your comments)

     

Comments and replies About How To Count Number Of Rows In A Mysql Query Get Total Count Rows




:: 1 :: #41926 - Reply By hostman On Mon Feb 18, 2008 9:23 pm
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);