PHP with DB
by Sanju[ Edit ] 2012-07-11 11:15:07
PHP with DB
<?php
$link = mysql_connect("localhost", "root", "");
$res1=mysql_select_db('testing',$link);
$query = "SELECT title FROM tt ORDER BY id ASC";
$result = mysql_query($query);
$total_records = mysql_num_rows($result);
$num_cols = 9;
$num_rows = ceil($total_records / $num_cols);
$num = 0;
echo "<table>n";
for ($rows = 0; $rows < $num_rows; $rows ) {
echo "<tr>n";
for ($cols = 0; $cols < $num_cols; $cols ) {
if ($num < $total_records) {
$titel = mysql_result($result, $num, "title");
$description = mysql_result($result, $num, "descr");
$url = mysql_result($result, $num, "link");
echo "<td><b>".$titel."</b>
".$description."<i><a href="".$url."">Visit here!</a></i><td>n";
} else {
echo "<td> </td>n";
}
$num ;
}
echo "</tr>n";
}
echo "</table>n";
?>