Page 1 of 1

Need help in displaying result as a table.........

Posted: Wed Dec 02, 2009 9:50 pm
by pokjak
Hi I am just wondering if anybody can help me with this matter...... I have write a program that will display result contained in the database..... the program is successful but I don't like the way it display the result...... Therefore I am wondering is there anyway that I can do so that my result will be displayed as a table....... something that looks like a table with columns.....

This is what I have done so far.....

<?

$conn = odbc_connect("denggi", "" , "" );

if (!$conn)
{exit("Connection Failed: ".$conn);}
$query="SELECT * FROM msjp_sample";
$result=odbc_exec($conn,$query);
if(!$result)
{exit("Error in SQL");}
echo '<h3>MS Access Powered Database</h3>';
while(odbc_fetch_row($result))

{
$e_name=odbc_result($result,"NAMA");
$bulan=odbc_result($result,"BULAN");
$e_date=odbc_result($result,"ONSET");

echo '<b>Nama:</b>'.$e_name.'<br>';

echo '<b>Bulan</b>'.$bulan.'<br /> <b>Date:</b>'.$e_date.'<br />
<hr/>';

}





odbc_fetch_row($result);


odbc_close($conn);
?>

Re: Need help in displaying result as a table.........

Posted: Thu Dec 03, 2009 1:33 am
by quaspam

Code: Select all

$conn = odbc_connect("denggi", "" , "" );
if (!$conn){
    exit("Connection Failed: ".$conn);
}
$query="SELECT * FROM msjp_sample";
$result=odbc_exec($conn,$query);
if(!$result){
    exit("Error in SQL");
}
echo '<h3>MS Access Powered Database</h3>';
echo '<table><tr><th>NAMA</th><th>NULAN</th><th>DATE</th></tr>';
while(odbc_fetch_row($result)){
    echo "<tr>";
    echo "<td>" . odbc_result($result,"NAMA") . "</td>";
    echo "<td>" . odbc_result($result,"BULAN"). "</td>";
    echo "<td>" . odbc_result($result,"ONSET"). "</td>";
    echo "</tr>";
}
echo "</table>";
odbc_fetch_row($result);
odbc_close($conn);

Re: Need help in displaying result as a table.........

Posted: Thu Dec 03, 2009 3:06 am
by pokjak
Thank you so much........................