maxic0 Posted September 8, 2006 Share Posted September 8, 2006 HiI know how to select users out of a table and display them, but how can i select users out of a table and link them to a seperate page.For example...If select someone out the database called "Bob", then the link would be..http://www.mydomain.com/members.php?user=bobPlease help me..Thanks Quote Link to comment Share on other sites More sharing options...
onlyican Posted September 8, 2006 Share Posted September 8, 2006 $query = "SELECT * FROM tablename";$result = mysql_query($query);if($result){while($row = mysql_fetch_assoc($result)){echo "<a href='page.php?user=".$row["username"]."'>".$row["username"]."</a><br />}} Quote Link to comment Share on other sites More sharing options...
maxic0 Posted September 8, 2006 Author Share Posted September 8, 2006 Thanks mate, ill try that in a bit.I have another question...When people change page on my site i only want the content bit to change..Can i use a script like...[code]<?php$page=$_GET['page'];include "$page.php";?>[/code] I dont think this would work, but is there a script similar to this?Can you post it here please.Thank you Quote Link to comment Share on other sites More sharing options...
onlyican Posted September 8, 2006 Share Posted September 8, 2006 That will work, but it is dodgy, u will need to validateWhat I would do is use a switchswitch($_GET["page"]){case "about";include("about.php");break;default:include("home.php");break;}But you do know this will still reload the page.What I do is create a header and footer includeInclude this on all page, and just naviagte to that page Quote Link to comment Share on other sites More sharing options...
maxic0 Posted September 8, 2006 Author Share Posted September 8, 2006 Ok thanks man.Im not bothered about it reloading, its just i will have a lot of pages and if a i want to change something in the header i only want to do it once.Thanks again. Quote Link to comment Share on other sites More sharing options...
onlyican Posted September 8, 2006 Share Posted September 8, 2006 my basic page layout is[code]<?php$page_title = "The Page Title";require("inc/inc_header.php");?>This is my Content<?phprequire("inc/inc_footer.php");?>[/code]in the inc header, I have the head, the page banner, the navigationIn the footer, I close the divs, and have my footerIf I want to change a link in the nav, in the footer or the header or something, I can in 2 secondsAnd each page is called with a unique nameindex.phpabout.phpcontact.php Quote Link to comment 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.