Re: POST a variable
| From: | Németh Zoltán | Date: | Fri, 23 Mar 2007 14:52:56 +0000 |
| Subject: | Re: POST a variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-251173@lists.php.net to get a copy of this message | ||
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
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
greets
Zoltán Németh