send a variable in a url

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chris_s_22
Forum Commoner
Posts: 76
Joined: Wed Dec 31, 2008 2:05 pm

send a variable in a url

Post by chris_s_22 »

in this script i connect to database and start session
from the search form collects data checks it the gets the appropriate data from database.
then displays it using code below

Code: Select all

 
while($row=mysql_fetch_array($result)) 
{
$userid = $row["id"];
$photo = $row["photo"];
echo "<td><img src='http://www.url.co.uk/images/$photo'>";
echo '<a href='view.php?userid=$userid'>' . $row['username'] . '</a>';
echo '<strong>Location:</strong>' . $row['location'] . '<br>';
echo '<strong>Date of Birth:</strong>' . $row['dob'] . '</td>';
} 
 
If you look particulary at this part im trying to send the id data recieved from database to the view.php

Code: Select all

 
echo '<a href='view.php?userid=$userid'>' . $row['username'] . '</a>';
 
Can yopu tell me the correct way to do this
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: send a variable in a url

Post by AbraCadaver »

mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
chris_s_22
Forum Commoner
Posts: 76
Joined: Wed Dec 31, 2008 2:05 pm

Re: send a variable in a url

Post by chris_s_22 »

figured it out thx
Post Reply