Page 1 of 1
[Solved]Num Count returns 1 no matter what
Posted: Sat Apr 10, 2004 9:25 pm
by Steveo31
Got a database with table 'members' and fields 'name', 'squad' so on and so forth.
Code: Select all
$num = mysql_query("SELECT COUNT(*) FROM members WHERE squad = '".$_GET['squad']."'");
$num_rows = mysql_num_rows($num);
Each name is in a specific squad, I would like to return how many names are in that squad. It comes back with one no matter what.
Do you need more info or...? Thanks.
Posted: Sat Apr 10, 2004 10:00 pm
by litebearer
perhaps try this
Code: Select all
$squad = $_GET('squad');
$query="SELECT * FROM members WHERE squad = '$squad'";
$result=mysql_query($query);
$num_rows = mysql_num_rows($result);
Posted: Sat Apr 10, 2004 10:00 pm
by Vicious
The double Quotes on $_GET['squad'] Will not work
Posted: Sat Apr 10, 2004 10:03 pm
by Vicious
or try
Code: Select all
$num = mysql_query("SELECT COUNT(*) FROM members WHERE squad =($_GETї'squad'])");
$num_rows = mysql_num_rows($num);
Posted: Sat Apr 10, 2004 11:36 pm
by Steveo31
litebearer wrote:perhaps try this
Code: Select all
$squad = $_GET('squad');
$query="SELECT * FROM members WHERE squad = '$squad'";
$result=mysql_query($query);
$num_rows = mysql_num_rows($result);
That did it. Thanks lite.
Posted: Sun Apr 11, 2004 4:51 am
by vigge89
Code: Select all
<?php
$num = mysql_query ("SELECT COUNT(*) FROM members WHERE squad = '{$_GET['squad']}'");
$num_rows = mysql_num_rows ($num);
?>
you forgot the qoutes.....