M8KWR Posted May 30, 2007 Share Posted May 30, 2007 I am new to PHP, i am able to insert and display data to the end user, but i am trying to let the end user edit a row. I am unsure how this is usually done, but i am have the following code to display by data echo "<table border='1'><thead><tr>"; for($i = 0;$i < mysql_num_fields($sql_result);$i++) { echo "<th>".mysql_field_name($sql_result,$i). "</th>"; } echo "</tr></thead> <tbody>"; for ($i=0;$i < mysql_num_rows($sql_result);$i++) { echo "<tr>"; $row = mysql_fetch_row($sql_result); foreach($row as $value) { echo "<td>".$value."</td>"; } echo "</tr>"; } echo "</tbody></table>"; The user have a jump menu (combo box) to pick the table they need to show information on, so the columns displayed are going to vary, but i have a column called ID which is the same in each tables which is the index (auto increment) field. I was thinking about using this number comnbined with a hyperlink, so the user can click it to take them to a page to edit that row.... But i have no idea how to do this, or if there is an easier way which i just do not know; or how do most people achieve what i require.......... any help or advice would be very much appreciated, and thanks in advance.... Quote Link to comment https://forums.phpfreaks.com/topic/53576-displaying-a-table-using-id-number-as-hyperlink/ Share on other sites More sharing options...
AndyB Posted June 2, 2007 Share Posted June 2, 2007 ... href="edit_me.php?iID=6" ... would be a link to the edit_me.php script. If you then abstract the passed id ... $ID = $_GET['ID']; you can then retrieve the database record that matches and carry on ... Quote Link to comment https://forums.phpfreaks.com/topic/53576-displaying-a-table-using-id-number-as-hyperlink/#findComment-266906 Share on other sites More sharing options...
penguin0 Posted June 2, 2007 Share Posted June 2, 2007 Not sure if you know this but along with what andyB said, you need to create an id colum in your users database. Then do something like this: $result = mysql_query( "SELECT * FROM users ORDER BY id" ); while ( $row = mysql_fetch_array( $result ) ) { $id = $row['id']; } then for which id the user has it will display in the link: <a href="edit_me.php?id=$id"> On the edit_me page: $id = intval($_REQUEST['id']); Quote Link to comment https://forums.phpfreaks.com/topic/53576-displaying-a-table-using-id-number-as-hyperlink/#findComment-267060 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.