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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pokjak
Forum Newbie
Posts: 7
Joined: Wed Dec 02, 2009 4:44 am

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

Post 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);
?>
quaspam
Forum Newbie
Posts: 2
Joined: Thu Dec 03, 2009 1:08 am

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

Post 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);
Last edited by John Cartwright on Thu Dec 03, 2009 3:21 am, edited 1 time in total.
Reason: please use [code=php][/code] tags
pokjak
Forum Newbie
Posts: 7
Joined: Wed Dec 02, 2009 4:44 am

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

Post by pokjak »

Thank you so much........................
Post Reply