Hi Everyone,
In my website i want to search data after submitting a query in the text box, for this purpose i had add a on textbox and one search button. but its not working i am unable to retrive information from my database.
Please find my code below.
<form action="search.php" method="post">
<input type=text name=search >
<input type=submit name=submit value=Search>
</form>
<?php
if(isset($_POST['submit'])) {
date_default_timezone_set('Asia/Calcutta');
$date=date("m/d/Y");
echo "Current Date Is = ";
echo "$date";
$con = mysql_connect("localhost","root","access");
if(!$con) {
die("Unable Connect To Database Server " .mysql_error());
}
$selectdb=mysql_select_db("baltimore",$con);
if(!$selectdb)
{
die ("Database Connection Error" .mysql_error());
}
$table="baltimore";
$sql= "select DATE,JOBNAME,INITIALS,TIME,TIMESTAMP from $table where DATE='{$_POST["submit"]}'";
$mydata=mysql_query($sql,$con);
if (isset($_POST['submit'])) {
echo "<table width=100% height=10% border=1>
<tr>
<th>DATE</th>
<th>JOBNAME</th>
<th>INITIALS </th>
<th>TIME</th>
<th>System TIMESTAMP</th>
</tr>";
}
while($records = mysql_fetch_array($mydata)){
echo "<tr>";
echo "<td>" . $records['DATE'] . "</td>";
echo "<td>" . $records['JOBNAME']. "</td>";
echo "<td>" . $records['INITIALS'] . "</td>";
echo "<td>" . $records['TIME'] . "</td>";
echo "<td>" . $records['TIMESTAMP'] . "</td>";
echo "<br>";
}
echo "</table>";
}
?>
I am not finding any error, But the strange thing is after loading my webpage table heading is display automatically, which i dont want this, i want my table show after fetching data, please guys do help me out.

