Jump to content

Recommended Posts

Hello all,

 

I am having trouble creating an $ID variable. Here is the deal, I am building a universal profile.php page where all of the data from my data tables will fall into that template, for example First Name: [$firstname]. The problem is that the $ID for these pages is not generated by a session. I need the site visitor to click a link and be directed to this profile.php. My problem is that I cannot figure out the link for the user to click and identify the $ID of the link that they clicked from my database.

 

Does anyone know the answer or have a better build suggestion??  :shrug:

Link to comment
https://forums.phpfreaks.com/topic/263274-user-page-id-trouble/
Share on other sites

Right, but im not really sure what the "id of those corresponding profiles" is. In my MYSQL database I have auto incrementing id numbers and last names, which is what I will id them by. How do I select that as the id in the corresponding link to the profile? For example link to Max Baldwin's profile.

Right, but im not really sure what the "id of those corresponding profiles" is. In my MYSQL database I have auto incrementing id numbers and last names, which is what I will id them by. How do I select that as the id in the corresponding link to the profile? For example link to Max Baldwin's profile.

 

In basic form, if Max Baldwin's ID in the db table is 547 then the link would be (something like):

 

http://www.your-site.com/profile.php?id=547

 

And on profile.php you would grab that ID from the URL and shove it in a query.

I just wanted to thank everyone for the help they have given me so far, but.....

 

The suggestion I was given was to use the following link on my website... www.mywebsite.com/profile.php?id=1

 

If I were to use this link I would have to input all of the code to the links like so....

<a href=http://www.mywebsite.com/profile.php?id=1><p>user's name<p><a>

 

Is there a way so I do not have to do this link for all of my 151 pages on a master profile list page?

 

Again, let me just fill you in, users are not making theses pages. I am creating these pages from the back end and I am using a standard profile.php. These pages are profiles of people that I am creating. There are no sessions!

 

Thanks again!  :D

Generate the list from your database

$sql = "SELECT id, lastname FROM profile ORDER BY lastname";
$res = mysql_query($sql);
while (list($id, $name) = mysql_fetch_row($res)) {
    echo "<a href='profile.php?id=$id' >$name</a><br/>
}

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.