Jump to content

[SOLVED] last sql query


Guardian-Mage

Recommended Posts

        $query2 = "SELECT shout_id FROM $database ORDER BY shout_id DESC";
        //The above query selects all shout entries and lists them in reverse
        //order so the newest ones are first
        $result2 = mysql_query($query2) //Executes the SQL Query
        or die("This script was unable to execute the SQL Query #2. Please
        contact the webmaster and inform them of the problem. Sorry for the
        inconvience.");

 

Now I need to take the last row from the above query and assign the value to the variable j

 

for example, the results come back like this:

755
754
753
752
751
...
$j = "755";

I would want $j to equal 755

Link to comment
https://forums.phpfreaks.com/topic/49124-solved-last-sql-query/
Share on other sites

$query2 = "SELECT shout_id FROM $database ORDER BY shout_id DESC";

       //The above query selects all shout entries and lists them in reverse

       //order so the newest ones are first

       $result2 = mysql_query($query2) //Executes the SQL Query

       or die("This script was unable to execute the SQL Query #2. Please

       contact the webmaster and inform them of the problem. Sorry for the

       inconvience.");

 

$show = mysql_fetch_object($result2);

 

$j = $show->shout_id;

 

 

That should do it.

 

Snowdog

 

 

Link to comment
https://forums.phpfreaks.com/topic/49124-solved-last-sql-query/#findComment-240693
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.