Ken2k7 Posted August 22, 2007 Share Posted August 22, 2007 Okay, this is pretty much a newbie question but say I have the url - http://blah.com/usercp.php? - and in that page, I have a table with 2 columns - one for navigation and the other for content - like the usercp of a forum. How do you php code it such that when a link is clicked, the content on the second column changes? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/66104-solved-same-page-on-link/ Share on other sites More sharing options...
pranav_kavi Posted August 22, 2007 Share Posted August 22, 2007 The table can have another field that holds a unique value for each row i.e primary key.this primary key can be used to update the content column.every time the link is clicked,get the particular 'id' and then update the row in table that corresponds to that 'id'. Quote Link to comment https://forums.phpfreaks.com/topic/66104-solved-same-page-on-link/#findComment-330623 Share on other sites More sharing options...
Ken2k7 Posted August 22, 2007 Author Share Posted August 22, 2007 The table can have another field that holds a unique value for each row i.e primary key.this primary key can be used to update the content column.every time the link is clicked,get the particular 'id' and then update the row in table that corresponds to that 'id'. I'm talking about the HTML table, not the database table. Unless you did get me, which in that case, I apologize. And if so, I don't even understand what you said. Quote Link to comment https://forums.phpfreaks.com/topic/66104-solved-same-page-on-link/#findComment-330627 Share on other sites More sharing options...
pranav_kavi Posted August 22, 2007 Share Posted August 22, 2007 sorry abt tat... r all the links and content in the html table got frm database initially? Quote Link to comment https://forums.phpfreaks.com/topic/66104-solved-same-page-on-link/#findComment-330632 Share on other sites More sharing options...
Ken2k7 Posted August 22, 2007 Author Share Posted August 22, 2007 sorry abt tat... r all the links and content in the html table got frm database initially? No, the links, I would put them in myself, but the contents are mostly received from the database. Sorry for the late reply. It's like a forum's usercp. The left panel contains the links and the right side contains the contents where you can edit. Quote Link to comment https://forums.phpfreaks.com/topic/66104-solved-same-page-on-link/#findComment-330670 Share on other sites More sharing options...
pranav_kavi Posted August 22, 2007 Share Posted August 22, 2007 The left panel contains the links and the right side contains the contents where you can edit. so tat means wen the user clicks on the link,the page gets refreshed and the content box is updated wid the new content.rite? can u post the code u ve done till now? Quote Link to comment https://forums.phpfreaks.com/topic/66104-solved-same-page-on-link/#findComment-330675 Share on other sites More sharing options...
Ken2k7 Posted August 22, 2007 Author Share Posted August 22, 2007 Well I haven't done much of the code since I'm already stuck at the link part of it. But I'll give you a general look without the real links: <table width='100%' border='0'> <tr> <td width='30%'> <a href='_link_here'>Profile Edit</a> <a href='_link_here'>Reports</a> </td> <td width='70%'> // contents displayed upon link </td> </tr> </table> I know there aren't any php there but that's because I don't even know how to use php and get that to work. That's just an example. It's not the real thing, but if you can help me on that one, I can do the rest. I just need to know what link to put in the <a> tag and how it will be used to get the contents onto the other <td> tag. Quote Link to comment https://forums.phpfreaks.com/topic/66104-solved-same-page-on-link/#findComment-330683 Share on other sites More sharing options...
pranav_kavi Posted August 22, 2007 Share Posted August 22, 2007 hope tis helps, <?php $action = $_REQUEST['action']; ?> <table width='100%' border='0'> <tr> <td width='30%'> <a href='http://localhost/temp.php?&action=profile_edit' >Profile Edit</a> <a href='http://localhost/temp.php?&action=reports' >Reports</a> </td> <td width='70%'> // contents displayed upon link <?php if(strlen($action)!=0) { if($action == "profile_edit") { //echo html code for profile } else if($action == "reports") { //echo html code for reports } } ?> </td> </tr> </table> pls note the url at d href tag should be chngd accordingly... Quote Link to comment https://forums.phpfreaks.com/topic/66104-solved-same-page-on-link/#findComment-330685 Share on other sites More sharing options...
Ken2k7 Posted August 22, 2007 Author Share Posted August 22, 2007 Yes, that helps tremendously, thank you! I just didn't know how to make the links. Do I really need the ampersand (&) in the <a href>? Quote Link to comment https://forums.phpfreaks.com/topic/66104-solved-same-page-on-link/#findComment-330691 Share on other sites More sharing options...
pranav_kavi Posted August 22, 2007 Share Posted August 22, 2007 Do I really need the ampersand (&) in the <a href>? s tats required... the url at the href wud point to the current file.to dynamically output the content between <td>-</td>,the value for the request variable-'action' needs to be set at the href. Quote Link to comment https://forums.phpfreaks.com/topic/66104-solved-same-page-on-link/#findComment-330694 Share on other sites More sharing options...
Ken2k7 Posted August 22, 2007 Author Share Posted August 22, 2007 Right, I get it now, but are these two the same? <a href='temp.php?action=report'>report</a> <a href='temp.php?&action=report'>report</a> Quote Link to comment https://forums.phpfreaks.com/topic/66104-solved-same-page-on-link/#findComment-330706 Share on other sites More sharing options...
pranav_kavi Posted August 22, 2007 Share Posted August 22, 2007 <a href='temp.php?action=report'>report[/url] <a href='temp.php?&action=report'>report[/url] sorry abt tat.both are d same(wont giv error!!).Only wen ther r more than one request parameters in url,'&' needs to be used to append them. Quote Link to comment https://forums.phpfreaks.com/topic/66104-solved-same-page-on-link/#findComment-330716 Share on other sites More sharing options...
Ken2k7 Posted August 22, 2007 Author Share Posted August 22, 2007 oh okay, thanks so much for your help, pranav_kavi. Much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/66104-solved-same-page-on-link/#findComment-330725 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.