Sunday, June 3, 2012

Showing data in ms access tables form php

Showing data in ms access tables using php

I have created "slvc.mdb" by using ms access and created Table1with the following fields.
ID,Name,Address,Qualifications, RegNumber, DateofReg, YearofGrad
Then stored it in web root.creating the fallowing php file you can view in your web interface.


<html>
<head>
</head>
<body>
<?php
$db_conn = new COM("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("slvc.mdb").";";
$db_conn->open($connstr);
$term = $_POST['term'];
$rS = $db_conn->execute("SELECT * FROM Table1");
$f1 =  $rS->Fields(0);
$f2 =  $rS->Fields(1);
$f3 =  $rS->Fields(2);
$f4=  $rS->Fields(3);
$f5 =  $rS->Fields(4);
$f6 =  $rS->Fields(5);
$f7 =  $rS->Fields(6);
echo "<center><table border='1' bgcolor='#f4e2ac'>";
echo "<tr><th>ID </th><th>Name</th><th>Address</th><th>Qualifications</th><th>Registration Number</th><th>Date of registration</th><th>Year</th></tr>";
while (!$rS->EOF)
{  

    echo "<tr><td>". $f1->value."</td><td>".$f2->value."</td><td>".$f3->value."</td><td>".$f4->value."</td><td>".$f5->value."</td><td>".$f6->value."</td><td>".$f7->value."</td></tr>";
    $rS->MoveNext();

}
echo "</center></table>";
$rS->Close();
$db_conn->Close();
?>
</body>
</html>

No comments:

Post a Comment