Page 1 of 1

how to get variables back out

Posted: Mon Dec 02, 2002 9:19 pm
by pelleas
okay. this is probably me just being stupid, but i've been looking at it for two days straight and am totally missing something. am trying to set up a news page that sends the browser to a user info page when they click on the poster's name. here's the code i'm using:

<news.php>

<?php
$result = mysql_query("SELECT * FROM news ORDER BY news_id DESC LIMIT 10",$mysql_connect);
while ($row= mysql_fetch_row($result)){
printf("<a name=\"$row[0]\"><p class=\"headline\">%s%s%s%s-%s%s-%s%s &nbsp; &nbsp; %s &nbsp; &nbsp; &nbsp; &nbsp; ...posted by <a href=\"user_info.php?userid=%s\">%s</a></a></p><p>%s</p>\n",
$row[1]{0}, $row[1]{1}, $row[1]{2}, $row[1]{3}, $row[1]{4}, $row[1]{5}, $row[1]{6}, $row[1]{7},
$row[2], $row[5], $row[4], $row[3]);
}
?>

<userinfo.php>

<?php
//pulls user number from titlebar, sets to $userid
$userid= $_GET['userid'];
//pull up all rows where user_id is the same as the value of userid
$result= mysql_query("SELECT * FROM user WHERE user_id='$userid'",$mysql_connect);
//for every row that is fetched
$row= mysql_fetch_array($result);
//prints the user's information fields
printf("<p class=\"headline\">User Information</p><em>&nbsp;<br /><b>User Name:</b></em><br />%s<br /><br /><em><b>User Status:</b></em><br />%s<br /><br /><em><b>User Email:</b></em><br />%s<br /><br /><em><b>User ICQ:</b></em><br />%s<br /><br /><em><b>User Website:</b></em><br /><a href=\"%s\">%s</a><br /><br /><em><b>User Location:</b></em><br />%s<br /><br /><em><b>User Comments:</b></em><br />%s\n",
$row[1], $row[4], $row[5], $row[6], $row[7], $row[7], $row[8], $row[9]);
?>

the thing is, i'm expecting it to automatically find out that the userid number is what's listed in the titlebar (say, something like http://www.yoursite.com/yourpage.php?userid=1)
but it's not able to pull that information out. am i screwing up when i send it the information? when i try to pull it out? argh!!!

any help would be insanely appreciated.

-pel