I am sorry but my search skills are weakening, and after rummaging through 20 or 30 threads about this topic, I haven't been able to find or understand what I need.
I'm trying to make a dynamic site and want to learn most of it on my own if possible, but I've been using a few tutorials and help on forums, the only problem I've come across is I cannot grab variables via the address of the page...
for example the filename would be mysqltest5.php?id=2
But I get an error message stating Notice: Undefined variable: id in c:\inetpub\wwwroot\mysqltest5.php on line 16
I know I need to use the new superglobals because I'm using PHP4, but how? and how do I define the id variable?
I'm using the same tired webmonkey tutorial:
<?php
$db = mysql_connect("localhost", "root");
$connection = mysql_connect("localhost") or die("Oops:".mysql_error());
mysql_select_db("mydb",$db);
// display individual record
if ($id) {
$result = mysql_query("SELECT * FROM employees WHERE id=$id",$db);
$myrow = mysql_fetch_array($result);
printf("First name: %s\n<br>", $myrow["first"]);
printf("Last name: %s\n<br>", $myrow["last"]);
printf("Address: %s\n<br>", $myrow["address"]);
printf("Position: %s\n<br>", $myrow["position"]);
} else {
// show employee list
$result = mysql_query("SELECT * FROM employees",$db);
if ($myrow = mysql_fetch_array($result)) {
// display list if there are records to display
do {
printf("<a href=\"%s?id=%s\">%s %s</a><br>\n", $_SERVER['PHP_SELF'], $myrow["id"], $myrow["first"], $myrow["last"]);
} while ($myrow = mysql_fetch_array($result));
} else {
// no records to display
echo "Sorry, no records were found!";
}
}
?>
I just want to know how to grab the id=2 which means probably a $_GET('id') somewhere, and a definition of this, but how and where?
btw, this is my 2nd day of php, sorry for how unbelievably Newbie I'm being.
Thanks!