Reputation: 349
I would like to get the max date from table but when I do this in PHP, it doesn't show any results.
$max_date = mysql_query("SELECT MAX(periodo) FROM mytable") or die (mysql_error());
$max_date = mysql_fetch_assoc($max_date);
$max_date = $max_date['periodo'];
It's not displaying any errors just doesn't showing something, but when I do that query directly in PHPMyAdmin it works, I have no idea what I'm doing wrong
Upvotes: 0
Views: 122
Reputation: 995
As @kamal pal said in his comment, you need to provide an alias for your column:
SELECT MAX(periodo) AS 'periodo' FROM mytable
Upvotes: 1