Pomtom44 Posted September 10, 2013 Share Posted September 10, 2013 Hey all.Im slightly new to PHP and MYSQL so sorry if my code is a mess and has "odd ways" of doing things.But it works for me so far and thats all that matter really isnt it?Anyway I have a php script that generates a table of information.What i would like is a Edit button for each row of that table so when pressed it will open a new page with a form where the user can update the fields for that entry. I have messed around a little bit with ideas i know from my limited HTML and PHP but can't seem to get it to workand not sure what to put when i google it so I cant seem to find a solution anywhereCurrently it is sending the last ID that it loads into the table no matter what edit button you press. Here is my current code echo "<table border='1'>"; echo "<tr> <th>Edit</th> <th>CardID</th> <th>Location</th> <th>Date Placed</th> <th>Found</th> <th>Date Found</th> <th>Found By</th> </tr>"; while($row = mysql_fetch_array($cards)) { echo "<tr><td>"; $cardID = $row['MemberCode'] . $row['CardID']; echo "<form action='../editcard.php' method='POST'>"; echo "<input type='hidden' name='CardID' value='"; echo $CardID; echo "'>"; echo "<input type='Submit' value='Edit'>"; echo "</td><td>"; echo $CardID; echo "</td><td>"; echo $row['Location']; echo "</td><td>"; echo $row['DatePlaced']; echo "</td><td>"; $found = $row['Found']; if ($found == 1) { echo "yes"; } else { echo "no"; } echo "</td><td>"; echo $row['DateFound']; echo "</td><td>"; echo $row['FoundBy']; echo "</td></tr>"; } echo "</table>"; Thanks for any help in advance Link to comment https://forums.phpfreaks.com/topic/282028-help-with-edit-entry-button/ Share on other sites More sharing options...
gristoi Posted September 10, 2013 Share Posted September 10, 2013 your not closing your form off after each loop. the </form> is missing. so you have ended up with a load of inputs with the same name (cardID) . php will be passed the last one in the form with that name Link to comment https://forums.phpfreaks.com/topic/282028-help-with-edit-entry-button/#findComment-1448956 Share on other sites More sharing options...
Pomtom44 Posted September 11, 2013 Author Share Posted September 11, 2013 your not closing your form off after each loop. the </form> is missing. so you have ended up with a load of inputs with the same name (cardID) . php will be passed the last one in the form with that name Ah is it something really that stupidly simple. I swear both my and my friend looked over this code so many times trying to figure this out. I shall try it now and let you know. Thanks for the help btw. (How did I miss that?) Link to comment https://forums.phpfreaks.com/topic/282028-help-with-edit-entry-button/#findComment-1449072 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.