Jump to content

Badly need help with this..


rn14

Recommended Posts

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

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.

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 :().

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

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.