In this code:
$Sql = "select * from $TableName where ID=What? ";
I want to go to last record that it's ID=last ID in the table.
Printable View
In this code:
$Sql = "select * from $TableName where ID=What? ";
I want to go to last record that it's ID=last ID in the table.
you want to display tha last ID or row in a table?
$Sql = "select * from $TableName order by ID DESC ";
that should work, make sure you only loop once as it will list all of them. hope thisis what you meant.
you can also append LIMIT to the end of that so it only returns 1 record
PHP Code:$Sql = "select * from $TableName order by ID DESC LIMIT 1";
or, to get the last id (if they're in order with no breaks), do:
PHP Code:$num = mysql_num_rows(mysql_query("SELECT * FROM $TableName"));
$sql = "SELECT $TableName WHERE ID='$num'";
that will not always work. if you have spaces in the rows like
1
2
3
6
8
9
it will only turn out 6 rows and your id will be 9
edit: sorry did see you said no breaks :)