What have I done wrong? - Date Range Selector
Posted: Sun Jun 22, 2008 7:38 pm
Hi there friends. I'm a newbie to PHP so please be kind.
I'm trying to recreate a date selector for my client but I'm getting this error "Parse error: syntax error, unexpected $end in C:\wamp\www\connectglobal\report_date.php on line 130"
I've grabbed this code from some place on the web and trying to make it work for my situation.
Thanks in advanced.
I'm trying to recreate a date selector for my client but I'm getting this error "Parse error: syntax error, unexpected $end in C:\wamp\www\connectglobal\report_date.php on line 130"
I've grabbed this code from some place on the web and trying to make it work for my situation.
Thanks in advanced.
Code: Select all
<html>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
<title>NZHC Report - Date</title><p><img src="images/hnzc-logo-home.gif" alt="NZHC Logo" /><img src="images/welcome_home_loan_07.gif" alt="Welcome Homeloan Logo" /></p>
| <a href="form_submit.php">Insert client info</a> | <a href="report.php">Total Report</a> | <a href="report_region.php">Region Report</a> | <a href="report_agent.php">Agent Report</a> | <a href="report_date.php">Date Range Report</a> |
<p>
<?php
// get variable after selecting something from the textbox with name 'dateStart'
$select = $_POST['dateStart'];
// if something has been chosen
if (!empty($dateStart)) {
// get the chosen value
$dateStart = $_POST['dateStart'];
// get variable after selecting something from the textbox with name 'dateEnd'
$select = $_POST['dateEnd'];
// if something has been chosen
if (!empty($dateEnd)) {
// get the chosen value
$dateEnd = $_POST['dateEnd'];
// select the type from the database
// database connection details (change to whatever you need)
$HOST = 'localhost';
$DATABASE = 'connect';
$USER = '****';
$PASSWORD = '****';
// connect to database
if(!$conn=mysql_connect('localhost','luke','shark1')) {
echo("<li>Can't connect to $HOST as $USER");
echo("<li>MySQL Error: ".mysql_error());
die;
}
// select database
if (!mysql_select_db($DATABASE,$conn)) {
echo("<li>We were unable to select database $DATABASE");
die;
}
// if everything successful create query
// this selects all rows where the type is the one you chose in the textbox
// * means that it will select all columns, ie name and type as i said above
$sql_query = "SELECT * FROM `info` WHERE date BETWEEN '$dateStart' AND '$dateEnd'";
// get the data from the database
$result = mysql_query($sql_query,$conn);
echo "<table border='1' cellpadding=5 cellspacing=0 bordercolor=#cccccc>
<tr>
<th>Call No.</th>
<th>Time</th>
<th>Title</th>
<th>Firstname</th>
<th>Surname</th>
<th>Gender</th>
<th>Street No.</th>
<th>Street</th>
<th>City</th>
<th>Region</th>
<th>Int Enquiry</th>
<th>Info Discussed</th>
<th>KiwiSaver</th>
<th>Info Requested</th>
<th>Referred</th>
<th>Source</th>
<th>Other</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['title'] . "</td>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['surname'] . "</td>";
echo "<td>" . $row['gender'] . "</td>";
echo "<td>" . $row['number'] . "</td>";
echo "<td>" . $row['street'] . "</td>";
echo "<td>" . $row['city'] . "</td>";
echo "<td>" . $row['region'] . "</td>";
echo "<td>" . $row['intEnquiry'] . "</td>";
echo "<td>" . $row['infoDiscussed'] . "</td>";
echo "<td>" . $row['kiwiSaver'] . "</td>";
echo "<td>" . $row['infoRequest'] . "</td>";
echo "<td>" . $row['referred'] . "</td>";
echo "<td>" . $row['source'] . "</td>";
echo "<td>" . $row['other'] . "</td>";
echo "<td>" . $row['agent'] . "</td>";
echo "</tr>";
}
echo "</table>";
// close mysql connection
mysql_close($conn);
}
?>
</p>
<form action="report_date.php" method="post">
<p>
<!-- This creates the textbox in html -->
Start Date
<input type="text" name="dateStart">
eg. 2008-06-20</p>
<p>End Date
<input type="text" name="dateEnd">
eg. 2008-06-20
<!-- Create a button -->
</p>
<p>
<input type="submit" value="Submit" name="select">
</p>
</form>