On 6/21/2013 10:09 AM, Karl-Arne Gjersøyen wrote:
Hello. I have an application that generete HTML5 form in PHP. The form is written in a while loop and therefore the form field has exact same name for every row in the loop. And that is the problem. Because when my PHP document shall handle submitted data it only take the very last row in the while loop and show the result of it. if(isset($_POST['update_explosive'])){ $item_serial_number = $_POST['item_serial_number']; $update_item_in_store = $_POST['update_item_in_store']; if($item_serial_number === "ETX1.22X1000"){ echo "<h1>$update_item_in_store</h1>"; } if($item_serial_number === "ETX1.17X460"){ echo "<h1>$update_item_in_store</h1>"; } } I think the solution will be to create different and unike fieldname dymamic. For example I tried to write <input type="text" name="<?php echo "$item_serial_number"; ?>" value="<?php echo "$item_serial_number"; ?>"> in the HTML5/PHP form. But the problem is that periode "." not is allowed as $variable_name. I then try to write it this way: if(isset($_POST['update_explosive'])){ $item_serial_number = $_POST['ETX1.22X1000']; $update_item_in_store = $_POST['update_item_in_store']; if($item_serial_number === "ETX1.22X1000"){ echo "<h1>$update_item_in_store</h1>"; } if($item_serial_number === "ETX1.17X460"){ echo "<h1>$update_item_in_store</h1>"; } } But this last part did not make any sense to me. I recive no output when tried that one. One problem is that I have between 2 and 25 items with different serial number. Sometimes only 5 of this shall be updated and other times all 25 items. I like to do this through one simple form and not for one time for every single item. (I know how to do when select one by one and update them, but that is a long and hard way for people using my application. A better solution is to just use one form and view all items there. Then just write the amount of item in <input type="number" name="update_item_in_store" size="6"> field.) If you have time to help me *understand* this newbie question by explain or give me an example or post a link to a tutorial that can help me though, I am very thankful. Karl
Make your names on your input tags like this: if you currently have <input type='text' name='field1'> then change it to this: <input type='text' name='field1[]'> This will give you an array of in your POST/GET array. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php