Page 1 of 1

SQL and PHP

Posted: Wed Sep 11, 2002 9:08 am
by Johnm
<?

Code: Select all

$sql="select count(name),max(name) from regen_vals 
         where job='".$session_info&#1111;'order']."'
             and loc_code='".$session_info&#1111;'loc_code']."'
              and name like 'UNIT%_LENGTH'";

$qry=ifx_query($sql,$dbid);
$row=ifx_fetch_row($qry,"next");
echo $row&#1111;'count']."=count\n"; 
echo $row&#1111;'max']."=max\n"; 
ifx_free_result($qry);

?&gt;
results in:
=count
=max

How do I refer to count(name) and max(name) in php after the querry?
I have echo'd out the querry and inserted it nativly into the database and gotten the results I expected so values for each are being returned. Any ideas?

Direwolf

Posted: Wed Sep 11, 2002 9:12 am
by twigletmac
Try:

Code: Select all

select count(name) AS count_name, max(name) AS max_name from regen_vals
then you can refer to them as

Code: Select all

$row&#1111;'count_name']
$row&#1111;'max_name']
Mac

Posted: Wed Sep 11, 2002 11:34 am
by Johnm
Hmmmm aliases... what a novel concept. <g>
Databases 101 I believe...
Thanks,
Direwolf