Jump to content

BenjaminDisco

New Members
  • Posts

    1
  • Joined

  • Last visited

BenjaminDisco's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi guys, Sorry im a bit of a noob when it comes to PHP but I just wondered if someone had an idea on how I could solve this PHP problem. I have a PDO statement that gets all users from a database. With the array of users from the database I create a foreach loop to display all of the users in a table which I want to use to select a specific user, enter a number in the row next to the user I select, then click submit and store the users name and also the number in vairables. I will use this information to populate another database later. My question is, I cant seem to reference the user or the number in the table to extract the user and number I enter. When I try and request the numbered entered in the index.php, it will only ever display a number if I enter a number for a the final user in the table. When I try and view the FullName it never works and I get 'Undefined index: FullName' error. I also specified to 'POST in the form but it doesnt seem to be doing that. Does anyone have any ideas? Thanks //function.php function getRequestors($tableName, $conn) { try { $result = $conn->query("SELECT * FROM $tableName"); return ( $result->rowCount() > 0) ? $result : false; } catch(Exception $e) { return false; } } //form.php <form action "index.php" method "POST" name='form1'> <table border="1" style="width:600px"> <tr> <th>Name</th> <th>Number Entered</th> <tr/> <tr> <?php foreach($users as $user) : ?> <td width="30%" name="FullName"><?php echo $user['FullName']; ?></td> <td width="30%"><input type="int" name="NumberedEntered"></td> <td><input type="submit" value="submit"></td> </tr> <?php endforeach; ?> </table> </form> //index.php if ( $_REQUEST['NumberedEntered']) { echo $_REQUEST['NumberedEntered']; echo $_REQUEST['FullName']; }
×
×
  • 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.