Notice: Undefined index: ID in C:\xampp\htdocs\Badbot\person.php on line 17
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Badbot\person.php on line 21
อันนี้ code list.php ครับ
Code (PHP)
<html>
<head>
<title>Retrieve data from the database</title>
</head>
<body>
<ul>
<?php
// Connect to database server
mysql_connect("localhost", "root", "") or die (mysql_error ());
// Select database
mysql_select_db("bbdatabase") or die(mysql_error());
// SQL query
$strSQL = "SELECT * FROM member ORDER BY Username DESC";
// Execute the query (the recordset $rs contains the result)
$rs = mysql_query($strSQL);
// Loop the recordset $rs
while($row = mysql_fetch_array($rs)) {
// Name of the person
$strName = $row['Username'] . " " . $row['UserEmail'];
// Create a link to person.php with the id-value in the URL
$strLink = "<a href = 'person.php?id = " . $row['UserID'] . "'>" . $strName . "</a>";
// List link
echo "<li>" . $strLink . "</li>";
}
// Close the database connection
mysql_close();
?>
</ul>
</body>
</html>
อันนี้ code person.php
Code (PHP)
<html>
<head>
<title>Retrieve data from database</title>
</head>
<body>
<dl>
<?php
// Connect to database server
mysql_connect("localhost", "root", "") or die (mysql_error ());
// Select database
mysql_select_db("bbdatabase") or die(mysql_error());
// Get data from the database depending on the value of the id in the URL
$strSQL = "SELECT * FROM member WHERE UserID =" . $_GET["ID"];
$rs = mysql_query($strSQL);
// Loop the recordset $rs
while($row = mysql_fetch_array($rs)) {
// Write the data of the person
echo "<dt>Name:</dt><dd>" . $row["Username"] . " " . $row["Userstatus"] . "</dd>";
}
// Close the database connection
mysql_close();
?>
</dl>
<p><a href="list.php">Return to the list</a></p>
</body>
</html>
Notice: Undefined index: ID in C:\xampp\htdocs\Badbot\person.php on line 17
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Badbot\person.php on line 21