Jump to content

Getting Values from a Textbox that is in a While Loop?


ZeTutorials101

Recommended Posts

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
Share on other sites

$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.

Edited by ZeTutorials101
Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.