Jump to content

Recommended Posts

Ok, I have read many tutorials but non of these tutorials talk about

.php?id=52

or something along the lines of that.

 

When they register to my site they will get an ID on my database

 

Can anybody help me with how to get that ID to make there personal part

mysite.com/profile.php?id=56

 

I hope I made some sense

Link to comment
https://forums.phpfreaks.com/topic/138324-struggling-on-phpid52/
Share on other sites

It is actually quite simple to do this. I'm assuming your users table has an id field

 

$sql = 'SELECT id, username FROM users_table WHERE username='your_username'";
$result = mysql_query($result);

$row = mysql_fetch_assoc($result);

echo '<a href="profile.php?id='.$row['id'].'">View '.$row['username'].'\'s Profile</a>';

 

In profile.php to retrieve the id you'd use $_GET['id']

 

profile.php

if(isset($_GET['id']) && is_numeric($_GET['id']))
{
    $user_id = (int) $_GET['id'];
    $sql = 'SELECT * FROM users_table WHERE id=$user_id";
    $result = mysql_query($result);

    $row = mysql_fetch_assoc($result);

    echo '<pre>'.print_r($row, true).'</pre>';
}

Im sorry but im realy confused.

 

I have a profile.php with what they need to do. When a person goes to the address bar and types .../profile.php?id=6 I need my secondary database which is called 'servers' to link to the table with the name of '6'.

 

Also it includes a text file named after the id.

 

I am sorry if I am confusing you aswell.

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.