I keep getting a notice saying Undefined index: id
. Also, the code does not do what it's meant to do. Its supposed to get data from the database where the ItemID = ID
. But the page just ends up blank.
Help please, what can I do?
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<link rel="stylesheet" href="my.css">
<title>Search result</title></head>
<body >
<div id = "header"> <h2> Descriptions and Images</h2></div>
<div id = "main">
session_start();
include(connect.php);
$id = isset($_GET['id']) ? $_GET['id'] : '';
//$id= $_GET['id'];
//$id = '';
//f( !isset( $_GET['id'])) {
// $id = $_GET['id']; }
//if ($id == ""){
// echo"eree";
//}
echo $id;
$query = mysql_query('SELECT * FROM PHP_Item WHERE ItemID = "$id"');
//$row = mysql_fetch_array($query);
while ($row = mysql_fetch_array($query)){
$Name = $row['Name'];
$Price = $row['Price'];
$Description = $row['Description'];
$Image = $row['Image'];
echo "<br /><br/>";
echo "Name: " . $Name;
echo "<br/>";
echo "Price: " . $Price;
echo "<br/>";
echo "Description: ".$Description;
echo "<br/>";
echo "<img src = '".$Image."' alt = '".$Image."'></img>";
echo"<br/><br/>";
}
?>
</div>
<div id = "footer">
<a href = "logout.php">Logout</a></div>
</html>