MySQL Forums
Forum List  »  PHP

Help with $PHP_SELF
Posted by: quipy
Date: March 04, 2006 01:00AM

Hi there,

I'm just starting out on PHP/MySQL and I'm having some trouble with a tutorial I'm working with (http://www.webmonkey.com/webmonkey/99/21/index3a_page3.html?tw=programming). Everything's been working fine up until this particular lesson. When one of the links are clicked, the whole page reloads and the selected (by 'id') table row item data would be displayed. Instead, I get the whole day reloading as it was. I can see in my browser's location that the appropriate suffix (php?id=2 when the second item is selected) is appended. But it still doesn't load the selected item.

Can anyone help?
...
if ($id) {

echo "Result:<br>";

$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 {

echo "Employee list:<br>";

// 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", $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!";

}

}
...

Options: ReplyQuote


Subject
Written By
Posted
Help with $PHP_SELF
March 04, 2006 01:00AM
March 05, 2006 08:05AM
March 07, 2006 04:14AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.