11
preachur
Re: Porting an MS-Access database
  • 2006/11/30 17:35

  • preachur

  • Just can't stay away

  • Posts: 525

  • Since: 2006/2/4 4


Actually, I could use that myself. I need to display 2 gigantic database tables of old forum posts and news stories as an archive type of deal.
Magick can never be restrained, but when freely given is thrice regained!

12
preachur
Re: Porting an MS-Access database
  • 2006/12/25 4:06

  • preachur

  • Just can't stay away

  • Posts: 525

  • Since: 2006/2/4 4


Hmmm.... I still need to do this. I wonder how I can?
Magick can never be restrained, but when freely given is thrice regained!

13
skenow
Re: Porting an MS-Access database
  • 2006/12/25 14:33

  • skenow

  • Home away from home

  • Posts: 993

  • Since: 2004/11/17


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_pwdSQL_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 ($result1);
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.

14
preachur
Re: Porting an MS-Access database
  • 2006/12/25 17:20

  • preachur

  • Just can't stay away

  • Posts: 525

  • Since: 2006/2/4 4


Wow, thanks! I wrote one to display it all, but it's about 60,000 messages and it crashes some browsers. I just need to figure out how to get it to output multiple pages and only show a certain number of rows on each page from the table now. (I am new at .php)
Magick can never be restrained, but when freely given is thrice regained!

Login

Who's Online

146 user(s) are online (102 user(s) are browsing Support Forums)


Members: 0


Guests: 146


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits