Hey! I have a link: http://webserver/view.php?id=5 I want script (view.php) to get the id, so then i can get info from my database depending on that id.... ?
view.php <? connection to database here $sql=mysql_query("SELECT * FROM table WHERE id='$id'") or die(mysql_error()); if (mysql_num_rows($sql)=="1") { while ($row=mysql_fetch_array($sql) { echo"$row[name]"; // echo the stuff from database echo"$row[age]"; } } if (mysql_num_rows($sql)=="0") { echo"No matching ID in the database"; } ?>
A note:
$id comes from the URL, and you may never assume that register_globals is on.
it is much better to use $HTTP_GET_VARS to get the values from the URL:
echo $HTTP_GET_VARS['id'];