Answer the question
In order to leave comments, you need to log in
Submitting a form via javascript, how to get the id of the last post?
if you just pass echo "1" - then in alert (data) - shows 1, and if
$query = "SELECT id FROM `post` ORDER BY id DESC Limit 0,1";
$result = mysql_query($query) or die(mysql_error());
echo $result['id'];
Answer the question
In order to leave comments, you need to log in
Thanks for the correction, this is how I solved it.
$query = "SELECT `id` FROM `post` ORDER BY `id` DESC LIMIT 1";
$result = mysql_query($query) or die(mysql_error());
$array = mysql_fetch_assoc($result);
echo $array['id'];
The mysql_query function returns a resource, not a query result. See example #2 php.net/manual/en/function.mysql-query.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question