InLikeMe Posted December 2, 2008 Share Posted December 2, 2008 Is there any particular PHP function which retrieves the max value of a query? To be specific: I have the query: $max_customer = mysql_query('SELECT max(customer_id) FROM customers'); and when I "echo" it echo $max_customer; I get "Resource id #3" When I use sql functions like mysql_ fetch_ array, mysql_ fetch_ assoc inside a while loop I get the word "Array". With mysql_ fetch_ object I get error. Is there any kind of "get_value" function? which will do sth like that --> $max_customer = get_value('SELECT max(customer_id) FROM customers'); Thnx Quote Link to comment Share on other sites More sharing options...
ranjuvs Posted December 2, 2008 Share Posted December 2, 2008 First of all you need fetch data from db using mysql_fetch_array or mysql_fetch_object $result = mysql_query('SELECT max(customer_id) as max_cust_id FROM customers'); $max_customer = mysql_fetch_array($result); echo $max_customer[0][max_cust_id]; Quote Link to comment Share on other sites More sharing options...
InLikeMe Posted December 2, 2008 Author Share Posted December 2, 2008 Thanx a looooooot....solved Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.