NameSilo

Would this...php/mysql question

SpaceshipSpaceship
Watch

liam_d

The original NP Emo KidEstablished Member
Impact
25
PHP:
$find_replies = mysql_num_rows(mysql_query("SELECT COUNT(id) FROM `forum_replies` WHERE `topic_id` = '".$_GET['topic']."'"));

would that set $find_replies to the amount of id's counted?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Yes, it looks like it should count all of the id replies to topic_id.

Is this what you want. Have you tried it?
 
0
•••
I don't think it does what you are looking for. That will always return a 1, because the SQL is going to return 1 row: "Count" that counts all the records where `topic_id` = '".$_GET['topic'].

You can do 1 of 2 things change the code to :

PHP:
 $find_replies = mysql_num_rows(mysql_query("SELECT * FROM `forum_replies` WHERE `topic_id` = '".$_GET['topic']."'"));

or

PHP:
$row = mysql_fetch_row(mysql_query("SELECT COUNT(id) FROM `forum_replies` WHERE `topic_id` = '".$_GET['topic']."'")); 
$find_replies = $row[0];
 
0
•••
PHP:
$find_replies=mysql_result(mysql_query("SELECT COUNT(id) FROM `forum_replies` WHERE `topic_id` = '".$_GET['topic']."'"),0);
should do the trick as well.
 
0
•••
i have done this and it works fine now;

PHP:
$count_replies = mysql_fetch_array(mysql_query("SELECT COUNT(id) AS `count` FROM `forum_replies` WHERE `topic_id` = '".$_GET['topic']."'"));
 
0
•••
Dynadot — .com TransferDynadot — .com Transfer
CatchedCatched

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back