Thread: PHP in a link?
View Single Post
  #2  
Old 01-28-2009, 04:42 PM
BMR777 BMR777 is offline
Member
 
Join Date: Jan 2011
Posts: 1,122
Gender: Male
Credits: 16,748
BMR777 is on a distinguished road
Default RE: PHP in a link?

I am assuming you have another application that you are trying to integrate into my script somehow?

If you know the username of a user you can easily find the ID and vise versa, assuming both scripts are running on a shared database. So, say you know the username of a user and you want to get their ID number, which is what I assume you want to do.

You would do:

PHP Code:
$username "Username Goes Here";
$username mysql_real_escape_string($username); //Prevent against SQL injection

//SQL query to get the ID number based on a username

$query "SELECT * FROM users WHERE username = '".$username."'";
$result mysql_query($query);
$num mysql_numrows($result);

//Loop out code
$i=0;
while (
$i 1) {

$uid=@mysql_result($result,$i,"uid");


$i++;
}

//Now we have the user's ID number, so we make a link...
echo "<a href='viewprofile.php?id=".$uid."'>Click Here</a>"
I hope this helps. If this isn't what you need please give me more info / examples of what you want to do and I'll try and help as best I can.

Brandon
Reply With Quote