13
This is kind of rough - but I have this working:
First the DB connection -
<?php
$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 #</th><th size = '10'>Ref #</th><th size = '10'>Store #</th><th size = '40'>Store Name</th><th size = '10'>Start Date</th><th size = '10'>End Date</th></tr>
<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
<?php
if (!$submit) {
echo "<h4> Your page title </h4><br/><hr>";
$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 ."*<br>";}
if ($storenum != ""){$where .= " AND (table.storeacct LIKE '$storenum%')";echo " Store # - ".$storenum ."*<br>";}
if ($storename != ""){$where .= " AND (table.groupname LIKE '$storename%')";echo " Store Name - ".$storename ."*<br>";}
if ($refno != ""){$where .= " AND (table.po_num LIKE '$refno%')";echo " Ref # - ".$refno ."*<br>";}
echo " Start Date - ".$startdate ."<br>";
echo " End Date - ".$end ."<hr>";
$qsel_calls = "SELECT _________ WHERE ".$where ." ORDER BY table.opendate DESC";
}
echo "<table width = 100% align='left' cellpadding='0'>";
echo "<tr bgcolor='#cccccc'><th size = '10'>Call #</th><th size = '10'>Ref #</th><th size = '10'>Date Opened</th><th size = '40'>Store</th><th size = '60'>Summary</th><th size = '10'>Status</th></tr>";
$result = odbc_exec($db_connection, $qsel_calls);
$firstrow = odbc_fetch_row ($result, 1);
while ($firstrow)
{
echo "<tr bgcolor='$rowcolor'><td align='right'><a href='your target link'>".odbc_result($result,"call_num")."</a></td>";
echo "<td align='right'>" .odbc_result($result,"po_num") ." </td>";
echo "<td>" .date("m/d/Y",strtotime(odbc_result($result,"opendate"))) ."</td>";
echo "<td>" .odbc_result($result,"groupname") ."</td>";
echo "<td>" .odbc_result($result,"summary") ."</td>";
echo "<td>" .odbc_result($result,"status") ."</td></tr>";
// echo "</a>";
$firstrow = odbc_fetch_row ($result);
}
echo "<tr><td colspan = '2'><b>End of List</b></td></tr></table>";
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.