ZeTutorials101 Posted May 23, 2013 Share Posted May 23, 2013 Hey guys, how can I get the value from a textbox that is in a while loop? Link to comment https://forums.phpfreaks.com/topic/278334-getting-values-from-a-textbox-that-is-in-a-while-loop/ Share on other sites More sharing options...
Jessica Posted May 23, 2013 Share Posted May 23, 2013 What? Are you saying you have multiple inputs? Make their names an array and you can then access the array in PHP <input type="text" name="fields[]"> And then $_POST['fields'] will have a useful array. Link to comment https://forums.phpfreaks.com/topic/278334-getting-values-from-a-textbox-that-is-in-a-while-loop/#findComment-1431940 Share on other sites More sharing options...
Q695 Posted May 24, 2013 Share Posted May 24, 2013 <input type="text" name="field" value="<?php echo"$_POST['field;];?>"> a post, and get are already arrays. Link to comment https://forums.phpfreaks.com/topic/278334-getting-values-from-a-textbox-that-is-in-a-while-loop/#findComment-1432014 Share on other sites More sharing options...
ZeTutorials101 Posted May 24, 2013 Author Share Posted May 24, 2013 $sql = mysql_query("SELECT * FROM hacker_log"); echo '<form action="" method="POST">'; while ($row = mysql_fetch_assoc($sql)){ $ip = $row['ip']; $time = $row['time']; $id = $row['id']; echo 'IP: $ip Time: $time <input type="hidden" name="id" value="'.$id.'"><input type="submit" name="remove" value="Remove From Log">'; } echo '</form>'; if (isset($_POST['remove'])){ echo $_POST['id']; } That is my code, but when I try it.. it doesn't work. Link to comment https://forums.phpfreaks.com/topic/278334-getting-values-from-a-textbox-that-is-in-a-while-loop/#findComment-1432016 Share on other sites More sharing options...
cyberRobot Posted May 24, 2013 Share Posted May 24, 2013 One problem is that you have one form and many hidden input fields named "id". When the form is submitted, you may not get the desired input. Link to comment https://forums.phpfreaks.com/topic/278334-getting-values-from-a-textbox-that-is-in-a-while-loop/#findComment-1432057 Share on other sites More sharing options...
Jessica Posted May 24, 2013 Share Posted May 24, 2013 That is my code, but when I try it.. it doesn't work. Did you even read the replies? My post explains how to do this. Link to comment https://forums.phpfreaks.com/topic/278334-getting-values-from-a-textbox-that-is-in-a-while-loop/#findComment-1432058 Share on other sites More sharing options...
cyberRobot Posted May 24, 2013 Share Posted May 24, 2013 Did you even read the replies? My post explains how to do this. It looks like the OP just wants the single ID for the item to remove. I would personally use anchor tags instead of the remove buttons and the HTML form. Link to comment https://forums.phpfreaks.com/topic/278334-getting-values-from-a-textbox-that-is-in-a-while-loop/#findComment-1432060 Share on other sites More sharing options...
Jessica Posted May 24, 2013 Share Posted May 24, 2013 It looks like the OP just wants the single ID for the item to remove. I would personally use anchor tags instead of the remove buttons and the HTML form.I agree, but the OP didn't make any effort to use anything we said so far, so... Link to comment https://forums.phpfreaks.com/topic/278334-getting-values-from-a-textbox-that-is-in-a-while-loop/#findComment-1432064 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.