Jump to content

Archived

This topic is now archived and is closed to further replies.

corillo181

help with this :|

Recommended Posts

i asked for help before but i still got nothing..

this is inside a loop..

nd it suposed to count how many is inside of what ever the id is

[code]

$myquery=mysql_query("select count(*) from comment WHERE p_id='".$onep['p_id']."'")or die(mysql_error());
while($times=mysql_fetch_array($myquery)){
$rows=mysql_num_rows($times);
echo $rows;
}


[/code]

i think the code is self explanatory.. i'm trying to count how many things are in side the table with the same id as the variable id..

Share this post


Link to post
Share on other sites
Well, if the query is not wrong, you can simply use this:

[code]$myquery = mysql_query("SELECT COUNT(...");
$rows = mysql_result($myquery, 0);[/code]

Share this post


Link to post
Share on other sites
<?php
$query = "SELECT * FROM comment WHERE p_id = '$your_variable'";
$result = mysql_query($query);

$num_rows = mysql_num_rows($query);

echo $num_rows;
?>

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.