porta325 Posted April 12, 2008 Share Posted April 12, 2008 Hey guys, i wanna do something like this: $var1 = $_POST['var1']; but i wanna doit dinamic; My ideea is something like this : $id = "1"; $var.$id = $_POST['var.$id']; Problem is it's not working. Any ideeas? i would apreciate. Thx. Link to comment https://forums.phpfreaks.com/topic/100772-var-_postvar/ Share on other sites More sharing options...
marklarah Posted April 12, 2008 Share Posted April 12, 2008 What? Could you please explain what you want a little more clearly please? Link to comment https://forums.phpfreaks.com/topic/100772-var-_postvar/#findComment-515402 Share on other sites More sharing options...
porta325 Posted April 12, 2008 Author Share Posted April 12, 2008 I have several generated textboxes. Each has a name like text1, text2, text3 and text4 After i post them to next page all i get is the last value. So the solution would be to write them manualy as: $text1 = $_POST['text1']; $text2 = $_POST['text2']; $text3 = $_POST['text3']; $text4 = $_POST['text4']; or to do something like $id1 = "1"; $id2 = "2"; $id3 = "3"; $id4 = "4"; and use $text.$id1 = $_POST['text$id1']; $text.$id2 = $_POST['text$id2']; .... and so on. The id's i take from a database using a while loop, it's just to make the example clear. Link to comment https://forums.phpfreaks.com/topic/100772-var-_postvar/#findComment-515403 Share on other sites More sharing options...
marklarah Posted April 12, 2008 Share Posted April 12, 2008 Ooooh okay. Dont do it manually, use $wi = "-1"; while (list($key,$value) = each($_POST)){ $wi++; $result1 = "SELECT * FROM `temp3` WHERE `ID` = '$key' "; Something like that Link to comment https://forums.phpfreaks.com/topic/100772-var-_postvar/#findComment-515424 Share on other sites More sharing options...
hellbringer Posted April 12, 2008 Share Posted April 12, 2008 @marklarah Very insecure! @porta325 Use Arrays: <input type="text" name="text[]" id="text1" /> <input type="text" name="text[]" id="text2" /> <input type="text" name="text[]" id="text3" /> $text = (array) $_POST['text']; Link to comment https://forums.phpfreaks.com/topic/100772-var-_postvar/#findComment-515430 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.