| Welcome to WebmasterWorld Guest from 184.108.40.206 |
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|
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.
I think you need to use SELECT...AS like so:
SELECT MIN( time ) AS `time` FROM `ordertable` WHERE company = 'Example'
Hmm, unfortunately that doesn't seem to have made a difference.
Thanks for the effort though.
$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.
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
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