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

 

Oh, the telepaths were fired.  They can't be afforded anymore (it's the economy :().

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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