Jump to content

creating a link


dan_t

Recommended Posts

Depends how your searching.

If your using a while, to loop out the results, you can use something similar to below.

<?php
$query = mysql_query("select * from zip codes"); //Change to match what you need
while($row = mysql_fetch_array($query) {
       echo '<a href="mylink.php?id='.$row['id'].'">$row['zipcode']</a>';
} ?>

 

This will bring up the zip codes, in a link to the page mylink.php?id=USERID

Providing mylink.php is setup correctly, so that it displays information based on the users id, then it'll work. :)

Link to comment
Share on other sites

Ok, I don't have any pages made, I'm just trying to understand this whole thing.

Perhaps I need to create some fake pages, but how does the zipcode attach an individuals personal page to it?

Meaning when you do a search and it pulls up and displays these zipcodes how is their personal pages linked to each page?

Through variables some how?

Or is it much more complicated.

Link to comment
Share on other sites

Well, you'd do similar to what I stated. For example, on mylink.php..

You could do this..

 

mylink.php

<?php
if($_GET['id']) {
      $id = $_GET['id'];
      $query = mysql_query("select * from users where id = $id") or die(mysql_error());
      if(mysql_num_rows($query) > 0) {
             $r = mysql_fetch_assoc($query);
             echo $r['username'] . '<br />';
             echo $r['email'];
      }
}
?>

 

So when the code I supplied before, is in place. it'll create a link on the persons zipcode, to their personal page on your site. The link put in the code, has a unique ID for each user being displayed. This will allow mylink.php to process it depending on that ID.

Clicking on it, takes you to 'mylink.php' The code above, will display details related to that particular user their viewing.

 

Is this what you're after?

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.