Jump to content

Mysql data links...


fesan

Recommended Posts

Hi.....

 

I have a mysql query... The data i get out of the query is listed in a table.

I want each row(or the first column on each row) to be a link that links directly to a "edit" page for the row.

How do i do that?

 

My main problem is to make one unique link for each row that actually links to something.

 

Thanks for any help!  :)

 

 

Link to comment
Share on other sites

Perhaps you could link to a form field that stores the current data (passed on from the previous table using POST or sessions), and (upon submission) sends it to an updating script that updates the particular column and field (using the sessions/post data) with the new entry found in form nr.2?

Link to comment
Share on other sites

Here is what I ahve done in the past. I show all data on the screen that I want to show and then add and edit link on the far right.

echo("      <a href='change_info2.php?admin_edit=edit&id=$id'>Edit</a>\n");   

 

That way it passed the row id onto the edit page and then when you make your changes you can update that row with your changes.

 

Snowdog                     

Link to comment
Share on other sites

Thanks...

 

2 things:

in the link example than you gave me,  i had some problems understanding this part: &id=$id

does the "&" have a function? This means that i have to have my id number in an variable?

 

And how do i get the id number out from the link addr in the "browser"?

 

 

I kind of new to this php thing... so be gentle with the advanced words an so on if that is possible! :)

 

 

Link to comment
Share on other sites

If you are not wanting the id to be displayed in the browser you would need to do this. With the link method I mentioned earlier,  only an administrator of my pages can see the id in the link so it was never a problem. If i wanted to keep it secret I would do it in a form and passs the variable through in a hidden input.

 

echo("<form method=\"POST\" action=\"your_processing_file.php\");
echo("your row of data here");
echo("<input type=\"hidden\" name=\"id\" value=\"$id\">\n");
echo("<input type=\"submit\" value=\"Edit\">");
echo("</form>");

and each line of your table would have this form in it.

 

If you were wondering how to retrieve the id number from the link then that is done on the your_processing_file.php page with this

 

$id = $_REQUEST['id'];

now you can do your query and get all information in the row you want to edit with the id number.

 

Snowdog

Link to comment
Share on other sites

There is no problem with the id showing in the browser. There will only be people internal in a compeny that will use this page.

 

I almost got it to work over here.  I just have some problems getting an variable out of the mysql databse.

But i'll fix it! (I hope :) )

 

Thanks very much for the help Snowdog!

I've learned some new things today! :)

 

 

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.