13
This is kind of rough - but I have this working:
First the DB connection -
$db_user = "user";
$db_pwd = "password";
$db='db_name'; \ something like "\\path\to\database.mdb";
$db_connection = @odbc_connect ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$db", $db_user, $db_pwd, SQL_CUR_USE_ODBC) or die("The database is unavailable at this time. Please try again later");
?>
Then, you'll need a form -
<FORM METHOD = "POST" ACTION = "yourpage.php">
<table width = '100%' class='table1'><tr><td align='center'>
<table class='table1'><tr><th size = '10'>Call #Ref # | Store # | Store Name | Start Date | End Date |
<tr> <td><input type = "text" name = "call" size = 10 value = "">td>
<td><input type = "text" name = "ref" size = 10 value = "">td>
<td><input type = "text" name = "store" size = 10 value = "">td>
<td><input type = "text" name = "name" size = 40 value = "">td>
<td><input type = "text" name = "start" size = 10 value = "">td>
<td><input type = "text" name = "end" size = 10 value = "">td>
tr>
<tr><td colspan='6' align='right'>
<input type = "submit" name = "submit" value = "Search">
<input type = "reset" name = "reset" value = "Clear">
td>tr>table>
td>tr>table>
FORM>
Then, the rest of the page
if (!$submit) {
echo " Your page title
";
$qsel_calls = $YourQueryString;
} else {
// do something w/ POST vars
$callnum = $_POST['call'];
$storenum = $_POST['store'];
$storename = $_POST['name'];
$startdate = $_POST['start'];
$enddate = $_POST['end'];
$refno = $_POST['ref'];
$where = "(table.opendate >= #$startdate#) AND (table.opendate <= #$enddate#) AND (table.accountnumber LIKE '$billto%')";
if ($callnum != "") {$where .= " AND (table.call_num LIKE '$callnum%')";echo " Call # - ".$callnum ."*
";}
if ($storenum != ""){$where .= " AND (table.storeacct LIKE '$storenum%')";echo " Store # - ".$storenum ."*
";}
if ($storename != ""){$where .= " AND (table.groupname LIKE '$storename%')";echo " Store Name - ".$storename ."*
";}
if ($refno != ""){$where .= " AND (table.po_num LIKE '$refno%')";echo " Ref # - ".$refno ."*
";}
echo " Start Date - ".$startdate ."
";
echo " End Date - ".$end ."
";
$qsel_calls = "SELECT _________ WHERE ".$where ." ORDER BY table.opendate DESC";
}
echo "";
echo "Call # | Ref # | Date Opened | Store | Summary | Status |
";
$result = odbc_exec($db_connection, $qsel_calls);
$firstrow = odbc_fetch_row ($result, 1);
while ($firstrow)
{
echo "$rowcolor'>".odbc_result($result,"call_num")." | ";
echo "" .odbc_result($result,"po_num") ." | ";
echo "" .date("m/d/Y",strtotime(odbc_result($result,"opendate"))) ." | ";
echo "" .odbc_result($result,"groupname") ." | ";
echo "" .odbc_result($result,"summary") ." | ";
echo "" .odbc_result($result,"status") ." |
";
// echo "";
$firstrow = odbc_fetch_row ($result);
}
echo "End of List |
";
odbc_close($db_connection);
?>
Be sure to use the other required elements for a XOOPS module - xoops_version.php, include XoopsRoot/header.php and footer.php.