Jump to content


Photo

Selecting USERS and LINKING them


  • Please log in to reply
5 replies to this topic

#1 maxic0

maxic0
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 08 September 2006 - 06:13 PM

Hi
I 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....rs.php?user=bob

Please help me..
Thanks

#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 08 September 2006 - 06:18 PM

$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 />
}
}
Tell me the problem, I will try tell you the solution

#3 maxic0

maxic0
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 08 September 2006 - 06:25 PM

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

<?php
$page=$_GET['page'];
include "$page.php";
?>


I dont think this would work, but is there a script similar to this?
Can you post it here please.

Thank you

#4 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 08 September 2006 - 06:33 PM

That will work, but it is dodgy, u will need to validate
What I would do is use a switch

switch($_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 include
Include this on all page, and just naviagte to that page
Tell me the problem, I will try tell you the solution

#5 maxic0

maxic0
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 08 September 2006 - 06:36 PM

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.

#6 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 08 September 2006 - 07:10 PM

my basic page layout is
<?php
$page_title = "The Page Title";
require("inc/inc_header.php");
?>
This is my Content

<?php
require("inc/inc_footer.php");
?>

in the inc header, I have the head, the page banner, the navigation
In the footer, I close the divs, and have my footer
If I want to change a link in the nav, in the footer or the header or something, I can in 2 seconds
And each page is called with a unique name

index.php
about.php
contact.php

Tell me the problem, I will try tell you the solution




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users