Jump to content

Problem with a querystring

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Pepozzo

Pepozzo

    Newbie

  • Members
  • Pip
  • 1 posts
I've a question on the generation of a query string.

I've a web form on a popup with this code (this is only a piece of code):

"<tr>  
<td><center><b>"; print ($espandi[$i]); echo "</b></center></td>
<td><input type='text' id='$articolo1_val_S_valore[$i]' name='$articolo1_val_S_$espandi[$i]' size='5'></td>  
<td><input type='text' id='$articolo1_val_M_valore[$i]' name='$articolo1_val_M_$espandi[$i]' size='5'></td>  
<td><input type='text' id='$articolo1_val_L_valore[$i]' name='$articolo1_val_L_$espandi[$i]' size='5'></td>  
<td><input type='text' id='$articolo1_val_XL_valore[$i]' name='$articolo1_val_XL_$espandi[$i]' size='5'></td>  
<td><input type='text' id='$articolo1_val_XXL_valore[$i]' name='$articolo1_val_XXL_$espandi[$i]' size='5'></td>      
</tr>"
Where $espandi[$i] will print a code took from the database.

Ok, now i must to create a querystring that contains $espandi[$i] and than the value of $articolo1_val_S_valore[$i] [etc etc]...so a "dynamic" query string "dinamica" because i won't know before how many codes ($espandi[$i]) i will have, while the number of the size (S, M, XL, XXL) is preset.

So, i would a querystring like this:
[B]inserimento_ordini.php?S=$espandi[$i]:$articolo1_val_S_valore[$i] ;$espandi[$i]:$articolo1_val_S_valore[$i].....&M=$espandi[$i]:
$articolo1_val_M_valore[$i];$espandi[$i]:$articolo1_val_M_valore[$i]...[/B]
for example:
inserimento_ordini.php?S=30:400;35:500.....&M=30:450;35:0...

I don't know if this is the best way, so i'll wait for your suggestions.

PS: the web-form will "create" and send the querystring to the opener window.

Edited by Jordan, 09 April 2009 - 06:48 AM.
Use code tags for long strings please


#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
I'd use a serialized string to pass the data of your array: PHP: serialize - Manual

It works well and is easy to serialize and the unserialize.

You could, also, store the entire array in a $_SESSION element, rather than passing by string like this. I don't see anything wrong with passing like you have it, though (aside from looking messy).

#3
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
Posted via CodeCall Mobile

could be good to urlencode the string so the ":", ";" and other chars is correctly sent.