| Welcome to WebmasterWorld Guest from 188.8.131.52 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|Problem retrieving MIN value from MYSQL statement|
| 9:08 am on Sep 4, 2007 (gmt 0)|
Hey there, another problem which I'm sure has a ridiculously easy answer but I just can't get at it.
I'm running an SQL statement to select a minimum value, here it is examplified:
SELECT MIN( time ) FROM `ordertable` WHERE company = 'Example'
and I know this is fine as I've run it in my database and it's all good.
I just can't find a way of printing this result or assigning it to a variable. The usually trusty...
while($row = mysql_fetch_array($result))
Is just giving me this:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/hhip99/public_html/admin/invoicehowards.php on line 111
I've tried about 15 different approaches but haven't had any joy. Would someone please put me out of my misery and hand me the simple solution! Thanks very much.
| 9:14 am on Sep 4, 2007 (gmt 0)|
I think you need to use SELECT...AS like so:
SELECT MIN( time ) AS `time` FROM `ordertable` WHERE company = 'Example'
| 9:59 am on Sep 4, 2007 (gmt 0)|
Hmm, unfortunately that doesn't seem to have made a difference.
Thanks for the effort though.
| 10:45 am on Sep 4, 2007 (gmt 0)|
$result = mysql_query($query);
If not set it, if it is, post that part of the code.
Also use the time in quotes `time` as time is a reserved word.
| 11:09 am on Sep 4, 2007 (gmt 0)|
Haha, yes Habtom! That's so funny. Well, I have to laugh to keep from crying :oD
I guess it's going to be one of those weeks!
Thanks for your help
| 1:55 pm on Sep 4, 2007 (gmt 0)|
I am glad you sorted it out.
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved