Jump to content


Photo

help with this :|


  • Please log in to reply
3 replies to this topic

#1 corillo181

corillo181
  • Members
  • PipPipPip
  • Advanced Member
  • 896 posts

Posted 31 May 2006 - 02:49 PM

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


$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;
}



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..

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 31 May 2006 - 02:56 PM

Well, if the query is not wrong, you can simply use this:

$myquery = mysql_query("SELECT COUNT(...");
$rows = mysql_result($myquery, 0);

~ D Kuang

#3 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 31 May 2006 - 02:57 PM

<?php
$query = "SELECT * FROM comment WHERE p_id = '$your_variable'";
$result = mysql_query($query);

$num_rows = mysql_num_rows($query);

echo $num_rows;
?>
wisewood: proven fact, I am both wise, and wooden.

#4 corillo181

corillo181
  • Members
  • PipPipPip
  • Advanced Member
  • 896 posts

Posted 31 May 2006 - 05:40 PM

thanx wise and thanx p for your assistance..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users