fesan Posted May 29, 2007 Share Posted May 29, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/53451-mysql-data-links/ Share on other sites More sharing options...
aeris130 Posted May 29, 2007 Share Posted May 29, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/53451-mysql-data-links/#findComment-264141 Share on other sites More sharing options...
snowdog Posted May 29, 2007 Share Posted May 29, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/53451-mysql-data-links/#findComment-264150 Share on other sites More sharing options...
fesan Posted May 29, 2007 Author Share Posted May 29, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/53451-mysql-data-links/#findComment-264183 Share on other sites More sharing options...
snowdog Posted May 29, 2007 Share Posted May 29, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/53451-mysql-data-links/#findComment-264236 Share on other sites More sharing options...
fesan Posted May 29, 2007 Author Share Posted May 29, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/53451-mysql-data-links/#findComment-264248 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.