SQL COUNT

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
prasadharischandra
Forum Commoner
Posts: 57
Joined: Thu May 09, 2002 2:19 am
Location: sri lanka
Contact:

SQL COUNT

Post by prasadharischandra »

$find_wait=mysql_query("select count(pas_dep_seat) as test from pase_res where pas_dep_flight='$fl_no' or pas_rtn_flight='$fl_no'") or die(mysql_error());

$find_test=mysql_num_rows($find_wait);
echo $find_test;
how i get counting out put?
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

if you're trying to find the number of rows try:

Code: Select all

$find_wait=mysql_query("select * from pase_res where pas_dep_flight='$fl_no' or pas_rtn_flight='$fl_no'") or die(mysql_error()); 

$find_test=mysql_num_rows($find_wait); 
echo $find_test;
that will print the number of rows that have $fl_no as pas_dep_flight and $fl_no as pas_rtn_flight

if this isn't what you want to find... then could you be a little more specific as in what you are trying to find
josa
Forum Commoner
Posts: 75
Joined: Mon Jun 24, 2002 4:58 am
Location: Sweden

Post by josa »

Your query will always return one row. It's the data returned that's interesting. Keep your original query and then do like this:

Code: Select all

$data = mysql_fetch_assoc($find_wait);
echo $dataї'test'];
This should be the most effective approach.

/josa
Post Reply