On Tue, 2002-02-05 at 15:12, Melanie Gann wrote:
> Thank you all you listeners out there. I'll try to be respectful of your
> time and patience, and apoligize in advance for my "greeness" - I am 2
> weeks into PHP/MySQL.
> I am trying to select the higest value from the column Thought_Num below.
> But it returns nothing. 
> <?PHP
> $db = mysql_connect("localhost", "root");
> mysql_select_db("DynaSite",$db);
> $result = mysql_query("SELECT MAX(Thought_Num) FROM quotes",$db);
> $myrow = mysql_fetch_array($result);
> print "the result is $myrow[Thought_Num]";
> ?>
> If I change my select to something that without the MAX (e.g. Select from
> quotes where DocID=1), the code works fine. 
> Thanks in advance for your help.

Essentially, your problem here is that your query 'SELECT
MAX(Thought_Num) FROM quotes' will return a column named
'MAX(Though_Num)'--so you either need to do this:

   print "the result is $myrow[MAX(Thought_Num)]";

Or, much preferably, explicitly name the column in the query:

   SELECT max(Thought_Num) as Thought_Num FROM QUOTES

...and then access it as you had before.
> Regards,
> Melanie

Hope this helps,


 Torben Wilson <[EMAIL PROTECTED]>

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to