Dynadot Black Friday and Cyber Monday 2026: save more on domains. See our sales.

Would this...php/mysql question

SpaceshipSpaceship
SpaceshipSpaceship
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
Close
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
Close
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
Close
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
Close
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
Close
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

New: watch any domain
You can now watch domains on NamePros. We check each one and notify you when something changes. Search for a domain and press Watch on...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back