SQL and PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

SQL and PHP

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

Hmmmm aliases... what a novel concept. <g>
Databases 101 I believe...
Thanks,
Direwolf
Post Reply