> -----Original Message-----
> From: Németh Zoltán [mailto:[EMAIL PROTECTED]
> 2007. 03. 23, péntek keltezéssel 10.45-kor Dan Shirah ezt írta:
> > Okay, I feel like the correct answer to this is about 2mm back
> in my grey
> > matter.
> >
> > 1. I have a query that pulls the last row number when a newly inserted
> > record is added:
> >
> > $maximum="SELECT MAX(payment_id) FROM payment_request";
> > $max_result=mssql_query($maximum);
> > while($max=mssql_fetch_row($max_result)){
> > }
> > $max_id = $max[0];
> >
> > 2. I have multiple selections for the user to pick, but
> regardless of what
> > they choose I want the $max_id variable to be passed to the next page.
> >
> > 3. Would I go about this by assigning $max_id to a hidden
> field like below?
> >
> > <input type="hidden" value="<?php echo "$max_id"; ?>" size="5"
> > maxlength="10" name="max_id" />
> >
> > 4. And then to retrieve this value on my next page just get it out of
> > $_POST['max_id'] ??
> >
> > Does that all sound correct?
>
> basically yes
Personally, I'd put it in a session variable. This reduces the amount of data
sent to/from the client and also stops anyone altering the value themselves.
> but if you want the id of the row you just inserted, using
> mysql_insert_id() is better because if another insert is happening at
> the same time, select max() may give you incorrect result
This would be true if he was using MySQL. The code given uses MSSQL and there
is no mssql_insert_id function (in my PHP manual).
Edward
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php