Re: Slecting data

From: Date: Wed, 11 Oct 2000 05:24:18 +0000
Subject: Re: Slecting data
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-19488@lists.php.net to get a copy of this message
At 08:48 PM 10/10/2000, you wrote:
Try using mysql_numrows: $query="SELECT id FROM table"; $result=mysql_query($query,$connection); $numrows=mysql_numrows($result); $query="SELECT * FROM table WHERE id=$numrows"; $result=mysql_query($query,$connection); That might not be the best way to do it, but it should work.
This would work so long as there has been no entries deleted before the last record. If for instance there were 5 records, and all 5 existed, then it would give you the last entry correctly. But if say, record 2 had been deleted, then it would only return 4 results, and take you to record ID 4, not 5. Personally, I would be looking more into the options available with the 'select' option, using something like a 'max(id)' to get the last entry (which in theory the last entry should have the highest number in the ID column) Chris --
      Chris Aitken - Webmaster/Database Designer - IDEAL Internet
email: chris@ideal.net.au phone: +61 2 4628 8888 fax: +61 2 4628 8890
            --------------------------------------------
      Unix -- because a computer's a terrible thing to waste!


« previous php.general (#19488) next »