I'm attempting to search a mysql database based on criteria entered by the user. The script here is attempting to pull an entry based on the product key. But, when I search for a key that I know exists in the table, nothing is returned. I am extremely new to php so this code could be completely wrong. This is my code:
<!DOCTYPE html PUBLIC "-//w3c//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="../css/style.css">
<title>
Inventory Home Page
</title>
<body>
<?php
$link = mysqli_connect("localhost", "myaccount", "mypass", "Inventory");
mysql_select_db("db_test", $link);
if(!$link){
die ("Could not connect: " . mysql_error($link));
}
$productKey = %product_key_search%;
$query = mysql_query("select * from PC where pk=$productKey") or die(mysql_error($link));
while($row=mysql_fetch_array($query)){
echo 'Product Key: ' .$row['pk'];
echo 'Make: ' .$row['make'];
echo 'Model: ' .$row['model'];
echo 'Type: ' .$row['type'];
echo 'Content: ' .$row['content'];
echo 'Status: ' .$row['status'];
echo 'Workstation: ' .$row['asset'];
echo 'Steam Account Number: ' .$row['steam_acct_num'];
}
?>
</body>
</html>
Please help..