NYCPHP Meetup

NYPHP.org

[nycphp-talk] passing variables to the next php page - HELP

Anirudh Zala arzala at gmail.com
Fri Aug 11 00:16:58 EDT 2006


If possible to change your code then better approach from HTML point of  
view is to declare your input variable as an array itself like shown below.

<input type="text" name="bid_sub_desc[]" value="val1" />
<input type="text" name="bid_sub_desc[]" value="val2" />
<input type="text" name="bid_sub_desc[]" value="val3" />

By this way you will receive values of all these input fields into single  
array "$_POST['bid_sub_desc']". Then you can do rest of stuffs with it  
just like you do with normal php array without bothering about handling  
"$i", "quotes", "expansion" and "concatenation"

Thanks

Anirudh Zala

On Fri, 11 Aug 2006 02:19:01 +0530, Néstor <rotsen at gmail.com> wrote:

> TNX!!!!
>
> that iw hat I was looking for.  I had done something like this
> about 3 years ago but I could not remember, but I new it could be done.
>
>
> Thanks again to all,
>
> Néstor :-)
>
> On 8/10/06, Rob Marscher <rmarscher at beaffinitive.com> wrote:
>>
>> switching the single quotes to double quotes should work also:
>> $query .= ",;" . $_POST["bid_sub_desc$i"] . ":";
>>
>> PHP expands variables enclosed in double quotes but leaves everything as
>> is if enclosed in single quotes.
>>
>> -Rob
>>
>>
>> Ken Robinson wrote:
>> > 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
>> >
>> > _______________________________________________
>> > New York PHP Community Talk Mailing List
>> > http://lists.nyphp.org/mailman/listinfo/talk
>> >
>> > NYPHPCon 2006 Presentations Online
>> > http://www.nyphpcon.com
>> >
>> > Show Your Participation in New York PHP
>> > http://www.nyphp.org/show_participation.php
>> >
>> _______________________________________________
>> New York PHP Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>>
>> NYPHPCon 2006 Presentations Online
>> http://www.nyphpcon.com
>>
>> Show Your Participation in New York PHP
>> http://www.nyphp.org/show_participation.php
>>



-- 
-----------------------------------------------
Anirudh Zala (Project Manager)
ASPL, http://www.aspl.in
Ph: +91 281 245 1894
arzala at gmail.com
-----------------------------------------------



More information about the talk mailing list