Hi new here, i'm having a small problem with my search.
I'm trying to build so that the search updates in the page, it isn't formatted yet; however everything seems to work but i get an error along with it and it's frustrating me.
<head>
<title>Welcome to the Book Store</title>
</head>
<body>
<form action="search2.php" method="post">
<p align="center">Book Name
<input type="text" name="Title" value="" id="Title"/><input type="submit" value="Search"/>
<br /> <br /> <br />
</form>
<?php
$var=0;
$connection = mysql_connect("localhost","","");
if (!$connection) {
die ("Database connection failed: ".mysql_error());
}
$db_select = mysql_select_db("book site",$connection);
if (!$db_select) {
die("Database selection failed: " . mysql_error());
}
$result = mysql_query("SELECT * FROM books WHERE Title LIKE '%$_POST[Title]%'");
while($row = mysql_fetch_array($result))
{
echo $row['Book_ID'] . " " . $row['Title'] . " " . $row['Cost'] . " " . $row['NoInStock'];
echo "<br />";
$var=1;
}
echo "<br />";
if ($var == 0){
echo ("No Search Results");
echo "<br />";
}
echo ("Last Search Completed : ");
echo(gmstrftime(" %a, %d/%m/%Y at %X ",time()));
?>
</p>
</body>
</html>
When it outputs i get the search results and the option for new entries, infact the whole search works but i get the following error
Notice: Undefined index: Title in C:\wamp\www\Books\search2.php on line 32
This seems to be this
$result = mysql_query("SELECT * FROM books WHERE Title LIKE '%$_POST[Title]%'");
I've bolded the part that is the problem, i can change this word to anything and i get the same error but the search works still, yet i cannot remove it because it breaks the page.
Please help, i'm at a loss.