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
•••
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
•••
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

New in Parking: updated way to act on many domains or inquiries at once
Your domain list and inquiry list now have a bar above and below the list. Check the items you want, then choose an action in the bar...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back