Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- get a single entry from a db


brotherhood_of_LAN - 11:35 pm on Feb 11, 2012 (gmt 0)


yes, array_shift will return the first element of an array and reduce the array's length by one. It's worth noting that in your example, 'field2' would be returned in 2 array values as per [php.net...]



The one line solution would be:

$desired_bit = array_shift(mysql_fetch_array(mysql_query("SELECT field2 FROM table1 WHERE row_ID = 7")));

but it would probably be sensible to see that the query did execute without a problem.


Thread source:: http://www.webmasterworld.com/php/4416623.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com