rn14 Posted October 19, 2008 Share Posted October 19, 2008 I have a database table with a number of different food options. I have created a small cms system and I want my admin to be able to edit that table with the food options. The user is presented with a page displaying all the food items and an edit button next to each one. The edit button is also stored in the database and is simply a link to the edit page. However when I select the edit button for each individual item it wont pass the id and details of that item to the edit page????? I use mysql_fetch_array() to loop through the database and present all the items in the table and then attempt to post the id value to the next page when the edit button of a particular option is selected. while($row = mysql_fetch_array($result)) { Print "<tr> <td>".$row['id'] . " </td> <td>".$row['title'] . " </td> <td>".$row['edit']." </td>; <td>".$show." </td>; <td>".$delete." </td></tr>"; } $id = $_POST['id']; From this code I want the id of the individual row which is selected to be$_POST Link to comment https://forums.phpfreaks.com/topic/129125-badly-need-help-with-this/ Share on other sites More sharing options...
Barand Posted October 19, 2008 Share Posted October 19, 2008 You may have noticed people are reading this post but no-one is replying. You can wait until one of our resident telepaths logs on or give us a clue about the button code stored in the database ( ??? ) and how you are currently attempting to pass the id. Link to comment https://forums.phpfreaks.com/topic/129125-badly-need-help-with-this/#findComment-669429 Share on other sites More sharing options...
DarkWater Posted October 19, 2008 Share Posted October 19, 2008 You may have noticed people are reading this post but no-one is replying. You can wait until one of our resident telepaths logs on or give us a clue about the button code stored in the database ( ??? ) and how you are currently attempting to pass the id. Oh, the telepaths were fired. They can't be afforded anymore (it's the economy ). Link to comment https://forums.phpfreaks.com/topic/129125-badly-need-help-with-this/#findComment-669431 Share on other sites More sharing options...
rn14 Posted October 19, 2008 Author Share Posted October 19, 2008 The button that is stored in the datbase is just a hyperlink to the edit.php page. The hyperlink is stored with each record in the database. The code behind that page is $ud_id = $_GET['id']; Print "$ud_id"; $link=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD)or die("Could not connect: " . mysql_error()); mysql_select_db("rossnoon14_simp"); $result = mysql_query("SELECT * FROM menus where id = $ud_id"); while($row = mysql_fetch_array($result)) { $data = $row['text']; $title = $row['title']; $image = $row['image']; } $ud_id = $_GET['id']; - This is the id which is meant to be passed from the code displayed in the first post? Does this explain better? Thanks Link to comment https://forums.phpfreaks.com/topic/129125-badly-need-help-with-this/#findComment-669439 Share on other sites More sharing options...
DarkWater Posted October 19, 2008 Share Posted October 19, 2008 Why is the link stored in the database? What does the link look like? Link to comment https://forums.phpfreaks.com/topic/129125-badly-need-help-with-this/#findComment-669441 Share on other sites More sharing options...
rn14 Posted October 19, 2008 Author Share Posted October 19, 2008 There is no reason for storing it in the database would prefer not too. What I want to do is so that when the user is is displayed with a table and a list of results for them to be able to click on the edit button of any result and then be displayed with the info. Basically I dont know how to make ("SELECT * FROM menus where id = $ud_id") id = to the users choice? Link to comment https://forums.phpfreaks.com/topic/129125-badly-need-help-with-this/#findComment-669448 Share on other sites More sharing options...
DarkWater Posted October 19, 2008 Share Posted October 19, 2008 You would just pass the ID of the result to an edit page through a URL, which would then use GET to do the query. Link to comment https://forums.phpfreaks.com/topic/129125-badly-need-help-with-this/#findComment-669463 Share on other sites More sharing options...
rn14 Posted October 19, 2008 Author Share Posted October 19, 2008 The only result I have is when I select all the fields from the database and then put them in an array. If I have an edit button next to each field how will that select the id that is displayed in that row of the table automatically??? Im sorry if this sounds stupid Link to comment https://forums.phpfreaks.com/topic/129125-badly-need-help-with-this/#findComment-669480 Share on other sites More sharing options...
DarkWater Posted October 19, 2008 Share Posted October 19, 2008 You'd generate the links with the ID on the end: $link = sprintf('edit.php?id=%d', $id); Then, on edit.php, you could use $_GET['id'] in a query. Link to comment https://forums.phpfreaks.com/topic/129125-badly-need-help-with-this/#findComment-669488 Share on other sites More sharing options...
rn14 Posted October 19, 2008 Author Share Posted October 19, 2008 Where will I then insert that in my code? Would I need to make any other changes Thanks again Link to comment https://forums.phpfreaks.com/topic/129125-badly-need-help-with-this/#findComment-669544 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.