我以前使用过这个代码的一个版本,它会像它应该的那样从左到右吐出我的内容。对于一个新项目,我无法以这种方式阅读它,并且正在寻求一些帮助。内容如下:
AAA
BBB
CCC
代替
ABC
DEF
这是它的外观和代码的链接,任何帮助将不胜感激,谢谢。
http://www.amphenol-industrial.com/test
<table style="width: 100%;" sizcache="14" sizset="0" border="0" cellpadding="0" cellspacing="0">
<tbody sizcache='14' sizset='0'>
<?
// Make a MySQL Connection
mysql_connect("localhost", "amphenol_web", "ampheweb") or die(mysql_error());
mysql_select_db("amphenol_conn") or die(mysql_error());
// Retrieve all the data from the "distributors" table
$query = "SELECT * FROM products WHERE page = '1' ORDER BY name";
$result = mysql_query($query) or die(mysql_error());
$cols = 6; // Here we define the number of columns
echo "<table>"; // The container table with $cols columns
do{
echo "<tr>";
for($i=1;$i<=$cols;$i++){ // All the rows will have $cols columns even if
// the records are less than $cols
$row=mysql_fetch_array($result);
?>
<?
$image = $row['image'];
$name = $row['name'];
$description = $row['description'];
$link = $row['link'];
$page = $row['page'];
if ($image == ""){echo "<td> </td>";}
else {echo
"<tr valign='top'>
<td><a href='$link'"?> onclick="_gaq.push(['_trackEvent', 'Clicks', 'Connectors', '<?php echo "$name"?>']);"><? echo "<img style='border: #015d90 1px solid;' alt='$name' src='/$image' height='74' width='120' /></a></td>
<td width='2'> </td>
<td><span style='font-family: andale mono,times; font-size: 8pt;'><b>$name:</b> $description</span></td>
<td><span style='font-family: andale mono,times; font-size: 8pt;'><b> </b></span></td>
<td><span style='font-size: 8pt;'><a href='$link'"?> onclick="_gaq.push(['_trackEvent', 'Clicks', 'Connectors', '<?php echo "$name"?>']);"><? echo "<img style='border: #015d90 1px solid;' alt='AC Threaded' src='$image' height='74' width='120' /></a></span></td>
<td width='2'> </td>
<td><span style='font-family: andale mono,times; font-size: 8pt;'><b>$name:</b> $description</span></td>
<td><span style='font-family: andale mono,times; font-size: 8pt;'><b> </b></span></td>
<td><a href='$link'"?> onclick="_gaq.push(['_trackEvent', 'Clicks', 'Connectors', '<?php echo "$name"?>']);"><? echo "<img style='border: #015d90 1px solid;' alt='$name' src='$image' height='74' width='120' /></a></td>
<td width='2'> </td>
<td><span style='font-family: andale mono,times; font-size: 8pt;'><b>$name:</b> $description</span></td>
</tr>
<tr>
<td height='25'> </td>
<td height='25'> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>";
}
}
// else{
// echo "<td> </td>"; //If there are no more records at the end, add a blank column
}
// }
// }
while($row);
echo "</table>";
?>
</tr>
</tbody>
</table>