I have a HTML form Having two fields From: and To: both are text fields(to genereate a report).I want to use these data to query on two tables based on the date specified(DD-MM-YYYY) i.e from and to and using these to select values from the two tables visitor_in and visitor_out each having same no. of fields except visitor_in has Time_In and other visitor_out has Time_Out.
Here's my code:
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("entry", $con); //entry is the database
$from=$_POST['from']; //values from
$to=$_POST['to']; //text fields of HTML form
// Construct our join query
$result = mysql_query("SELECT visitor_in.Name,visitor_in.Contact_Number,visitor_in.Date,visitor_in.Time_In,visitor_out.Time_Out FROM visitor_in,visitor_out WHERE visitor_in.Date BETWEEN '$from' AND '$to' ") or die(mysql_error());
//Printing as a HTML table
echo "<table border='1'>
<tr>
<th>Name</th>
<th>Contact Number</th>
<th>Date</th>
<th>Time In</th>
<th>Time Out</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['visitor_in.Name'] . "</td>";
echo "<td>" . $row['visitor_in.Contact_Number'] . "</td>";
echo "<td>" . $row['visitor_in.Date'] . "</td>";
echo "<td>" . $row['visitor_in.Time_In'] . "</td>";
echo "<td>" . $row['visitor_out.Time_Out'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
After I input form field with date(DD-MM-YYYY) no result is yielded only the table headings Name contact number date time in time out appear but not the rows to be selected. Im using WAMP server.