I have the below code which gives a user a page to input a date. Once update is clicked it should call a function 'getitems' and run the query and display the data I thought. Am I missing something?
Thanks.
<?
$title = "Test";
echo "<table width=100% cellspacing=0 cellpadding=0 border=0 bgcolor='#000099'><tr><td>";
echo "<table width=100% bgcolor='#000099'><tr>";
echo "<td align='center'><font class='text14bold'' color='#ffffff'>".$title."</font>";
echo "</b></font><font class='text12'> </font></td>";
echo "</b></font>";
echo "</td></tr></table>\n";
echo "</td></tr></table>\n";
echo "<table width=100% cellspacing=0 cellpadding=0 border=0 bgcolor='#000099'><tr><td>";
echo "<img src='images/spacer.gif' width=100 height=7>";
echo "</td></tr></table>\n";
echo "<table width=100% bgcolor='#eeffee' class='reportsborder' cellspacing=1 cellpadding=1>";
echo "<tr valign='top' align='left'>";
echo "<td class='text18bold' width=100% align='center'>".$title."</td></tr></table>";
echo "<form name='GetDatesAndShift' action='".$_SERVER['PHP_SELF']."' method='get'>";
echo "<input type='hidden' name='action' value='getitems'>";
// echo "<input type='hidden' name='action' value='".$link."'>";
echo "<table width=100%><tr bgcolor='#ffffff'>";
// Enter One Date
echo "<td class='boxtext10bold' width=50% bgcolor='#eefee' align='center'><input type='text' name='startdate' value='".date("Y-m-d")."' size=20> <small><a href='javascript:showCal(\"CalendarStart\")'>Select Date</a></small></td></tr></table>";
/* Enter A Date Range
echo "<td class='boxtext10bold' width=50% bgcolor='#eefee' align='center'><input type='text' name='startdate' value='".date("Y-m-d")."' size=20> <small><a href='javascript:showCal(\"CalendarStart\")'>Select Start Date</a></small></td>";
echo "<td class='boxtext10bold' width=50% bgcolor='#eefee' align='center'><input type='text' name='enddate' value='".date("Y-m-d")."' size=20> <small><a href='javascript:showCal(\"CalendarEnd\")'>Select End Date</a></small></td></tr></table>";
*/
echo "<p align='center'><input type='image' src='images/update.jpg' border=0 width=88 height=27 value='Submit' name='submit'>";
echo "</p></form>";
echo "<script language=\"JavaScript\">\n";
echo "document.GetDatesAndShift.startdate.focus();\n";
echo "</script>";
function getitems($startdate) {
$start = substr($startdate,0,4).substr($startdate,5,2).substr($startdate,8,2);
$login = "name";
$pass = "";
$ODBCName = "HST";
//connect to the database
$conn = odbc_connect($ODBCName,$login,$pass);
echo "connect: $conn";
if ($conn <=0){
echo "Error in connection<BR>";
Return false;
}
//SQL query
$query = "SELECT FPORDDTL.OTCBIL, FPORDDTL.OTINV#, FPORDDTL.OTIVDT,";
$query .=" FPORDDTL.ORDTIT, FPORDDTL.ORDTDS, FPORDDTL.ORDTQT,";
$query .=" FPORDDTL.ORDTSQ FROM FPORDDTL WHERE (FPORDDTL.OTIVDT = ".$start." AND FPORDDTL.ORDTQT = 0 AND FPORDDTL.ORDTSQ = 0)";
//execute query
$result = odbc_exec($conn, $query);
//query database
while(odbc_fetch_row($result))
{
$custno = odbc_result($result, 1);
$invno = odbc_result($result, 2);
$invdate = odbc_result($result, 3);
$itemno = odbc_result($result, 4);
$desc = odbc_result($result, 5);
$ord = odbc_result($result, 6);
$shp = odbc_result($result, 7);
//format results
print ("<tr>");
print ("<td>$custno</td>");
print ("<td>$invno</td>");
print ("<td>$invdate</td>");
print ("<td>$itemno</td>");
print ("<td>$desc</td>");
print ("<td>$ord</td>");
print ("<td>$shp</td>");
print ("</tr>");
}
//disconnect from database
odbc_close($conn);
}
?>