[nycphp-talk] passing variables to the next php page - HELP
Ken Robinson
kenrbnsn at rbnsn.com
Thu Aug 10 15:58:40 EDT 2006
At 03:39 PM 8/10/2006, Néstor wrote:
>People,
>
>In one PHP page I have an input field name
>bid_sub_desc0, bid)sub_desc1, etc...
>Whe I am in my next PHP page I am try to move
>the different values to single variable
>to later added it a query. bid sub tell me how many bids where entered.
> for($i=0; $i < count($bid_sub); $i++)
> {
> $query .= ",;" . $_POST['bid_sub_desc$i'] . ":";
> }
>
>When I print print "QUERY =$query|<br>\n";
>I get nothing :
> QUERY=,':','::')|
>
>The varable inside the $_POST is no getting refered to the way I want it to.
>I was expecting the bid_sub_desc$1 to change to:
>bid_sub_desc0
>bid_sub_desc1
>etc
>depending on the $bid_sub
Your problem is occurring because you're enclosing the index in single quotes.
Change
$query .= ",;" . $_POST['bid_sub_desc$i'] . ":";
to
$query .= ",;" . $_POST['bid_sub_desc'.$i] . ":";
If you can change the names on the form to
arrays, it would make your life much easier. Then
instead of checking for $_POST['bid_sub_desc'
.$i], you could use $_POST['bid_sub_desc][$i]
Ken
More information about the talk
mailing list