deansaddigh Posted January 8, 2010 Share Posted January 8, 2010 I am trying to get the oldest arrival_date from my db and i have this code /*Build sql query*/ $yearsql = mysql_query("SELECT * FROM bookings order by arrival_date desc"); /*Get the last arrival_date e.g the oldest*/ echo $yearresult = mysql_result($yearsql ,arrival_date); But it returns the number 852 Does anyone know why this is? Also the arrival_date field in the db isnt a date type, some one put it in as a string so the date looks like this 20092019 etc Link to comment https://forums.phpfreaks.com/topic/187690-is-this-code-correct/ Share on other sites More sharing options...
r-it Posted January 8, 2010 Share Posted January 8, 2010 $yearsql = mysql_query("SELECT * FROM bookings order by arrival_date desc LIMIT 1"); if(@mysql_num_rows($yearsql) > 0) { while($a = mysql_fetch_array($yearsql)) { echo $a['arrival_date']; } } check that your database fields are named correctly though Link to comment https://forums.phpfreaks.com/topic/187690-is-this-code-correct/#findComment-990872 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.