Re: getting last entry in database table
| From: | Martin Skjöldebrand | Date: | Sat, 17 Mar 2001 19:02:24 +0000 |
| Subject: | Re: getting last entry in database table | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-7566@lists.php.net to get a copy of this message | ||
Martin Skjöldebrand wrote:
> I have a table containing steps toward solving a problem. I want to pass
> the last entry to another database as a solution.
> How do I do this? What I've tried today is:
I read a few more pages in my newbie book and decided to try it like this
instead:
<? if (isset($cmdAddtoKb)) {
$querykb ="SELECT e_description FROM events WHERE t_id = '$t_id';";
$resultkb = mysql_query($querykb, $mysql_link);
$answer = mysql_fetch_row($resultkb);
foreach ($answer As $teststring) //while we are inside the array
{
$kb_answer = $teststring; //pass the current string to the final
variable
}
I've got two entries in e_description:
note 1
note 2
Still $kb_answer refuses to become anything other than "note 1". What I'm
looking to do it to get it to be "note 2" or rather the *last* entry in the
table e_description that fits the SELECT statement (there might be 1,2, 7
or 94 entries. I still want $kb_answer to be the last one).
Frustrating being a newbie,
Martin S.