Forum Moderators: coopster
<td>
<table>
<tr valign="top">
<td></td>
<td>
<b><a href='<?=$row['link'] ?>'><?=$row['sitename'] ?></a></b><br />
</td>
<td width="25%"> </td>
</tr>
</table>
</td>
[edited by: dreamcatcher at 7:21 am (utc) on May 5, 2010]
[edit reason] no urls please, see T.O.S [/edit]
<?
$query = "SELECT * FROM linksites"; //
$result=mysql_query($query);
$cols=4;
echo "<table>";
do{
echo "<tr>";
for($i=1;$i<=$cols;$i++){
$row=mysql_fetch_array($result);
if($row){
?>
<td>
<table>
<tr valign="top">
<td><img src="image.src"></td>
<td>
<a href='<?php echo $row['link']; ?> '><?php echo $row['sitename'];?</a>
</td>
<td width="25%"> </td>
</tr>
</table>
</td>
<?
}
else{
echo "<td> </td>";//If there are no more records at the end, add a blank column
}
}
} while($row);
echo "</table>";
?>
i'm getting the link error
<?php
$cols=4;
$colcount=0;
$output=null;
$query = "SELECT * FROM linksites";
$result=mysql_query($query);
while ($row=mysql_fetch_array($result)) {
if ($colcount==0) { $output .= '<tr>'; }
// Check to make sure LINK has http or https
$link = (preg_match('/^https*:\/\/.*/i',$row['link']))?$row['link']:'http://' . $row['link'];
$output .= '
<td><a href="' . $link . '">' . $row['sitename'] . '</a></td>
';
$colcount++;
if ($colcount >= $cols) { $output .= '</tr>'; $colcount=0; }
}
// now, if the last row ends unevenly, fill it out.
if ($output) {
if (($colcount > 0) and ($colcount < $cols)) {
for ($i=$colcount;$i<$cols;$i++) {
$output .= '<td> </td>';
}
$output .= '</tr>';
}
$output = "<table>$output</table>";
}
else { $output = '<p>No records to display.</p>'; }
echo $output;
?>