Lee-Bartlett Posted October 6, 2008 Share Posted October 6, 2008 Ok i think i am close but im not sure how to get this to work, i want my button in the update row, to update that row of data, here my code. Im not sure what to do, to get the data from the first page to use on the second <?php require_once("includes/db_connection.php"); ?> <?php $name = $_POST['name']; $email = $_POST['email']; $location = $_POST['location']; $type = $_POST['type']; $buissnes_name = $_POST['buissnes_name']; $id = $_POST['id']; ?> <?php if(isset($_POST['id'])) { $id = $_POST['id']; $delete = mysql_query("DELETE FROM tblbasicform WHERE id='$id'"); } $sql = "SELECT * from tblbasicform"; $res = mysql_query($sql) or die(mysql_error()); echo "<table border=1 align=centre>"; echo "<tr><td>id</td> <td>Name</td><td>Email</td><td>Buissnes Name</td><td>Location</td><td>Free or Paid</td><td>Delete</td><td>Update</td></tr>"; while($row = MYSQL_FETCH_ARRAY($res)) { echo "<tr><td><form action="'.basename($_SERVER['PHP_SELF']).'" method="POST">".$row['id']."</td>"; echo "<td>".$row['name']."</td>"; echo "<td>".$row['email']."</td>"; echo "<td>".$row['buissnes_name']."</td>"; echo "<td>".$row['location']."</td>"; echo "<td>".$row['type']."</td>"; echo '<td><form action="'.basename($_SERVER['PHP_SELF']).'" method="POST"> <input type="hidden" name="id" value="'.$row['id'].'"><input type="submit" name="button=" id="button" value="Delete Record"></form></td>'; echo "<td>( <a href=form2.php>Update</a> ) </td></tr>"; } echo "</table><br>"; ?> <a href="userform.php">Add a new user.</a> it then links to <?php require_once("includes/db_connection.php"); $name = $_POST['name']; echo "<form action=\"form3.php\" method=\"post\">"; $sql = "SELECT * from tblbasicform WHERE name = '$name'"; $res = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($res)){ $id = $row['id']; $name = $row['name']; $email = $row['email']; $buissnes_name = $row['buissnes_name']; $location = $row['location']; $type = $row['type']; ?> Input Name: <input type="text" name="name" value="<? echo $name ?>" /><br /> Input Email: <input type="text" name="email" value="<? echo $email?>" /><br /> Input Buissnes Name: <input type="text" name="buissnes_name" value="<? echo $buissnes_name?>" /><br /> Input Location: <input type="text" name="location" value="<? echo $location?>" /><br /> Input Free or Paid: <input type="text" name="type" value="<? echo $type?>" /><br /> <input type="hidden" name="id" value="<? echo $id?>"> <input type="submit" name="submit" value="Update Data" /> </form> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/127303-updateing-a-data-base-row/ Share on other sites More sharing options...
revraz Posted October 6, 2008 Share Posted October 6, 2008 What I do is use a Link instead, that includes the ID and the action. I use GET to get the action (delete) and use GET to get the ID at the same time. Link to comment https://forums.phpfreaks.com/topic/127303-updateing-a-data-base-row/#findComment-658423 Share on other sites More sharing options...
Lee-Bartlett Posted October 6, 2008 Author Share Posted October 6, 2008 so instead of $post i should use GET? Link to comment https://forums.phpfreaks.com/topic/127303-updateing-a-data-base-row/#findComment-658430 Share on other sites More sharing options...
revraz Posted October 6, 2008 Share Posted October 6, 2008 Well that was how I did my code, you couldn't just change POST to GET in yours and have it work. Link to comment https://forums.phpfreaks.com/topic/127303-updateing-a-data-base-row/#findComment-658434 Share on other sites More sharing options...
Lee-Bartlett Posted October 6, 2008 Author Share Posted October 6, 2008 What else needs to be done? i think i aint linking to form2.php properly to carry over the data. Link to comment https://forums.phpfreaks.com/topic/127303-updateing-a-data-base-row/#findComment-658438 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.