在两列表中显示MySQL数据

时间:2011-11-30 20:35:17

标签: php mysql html database

我有一个MySQL表,里面有大约50条记录。我希望每条记录都列为<li>,我希望每列的分布均匀......所以基本上一方25条,另一条25条。

以下是我想要输出的内容:

<li><a href='datasheets/shielded/".$row['Link']."' class='tt'/>".$row['P/N']."<span class='tooltip'><span class='top'></span><span class='middle'>
    <strong>".$row['Description']."</strong><br />
    ".$row['Min L']."".$row['Min L Val']." to ".$row['Max L']."".$row['Max L Value']."<br />
    <strong>DCR(".$row['DCR Val']."):</strong> ".$row['Min DCR']." to ".$row['Max DCR']."<br />
    <strong>Rated DC (".$row['DC Val']."):</strong> ".$row['Min DC']." to ".$row['Max DC']."<br />
    ".$row['Other Info']."</span><span class='bottom'></span></span></a></li>

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

我不明白,你的意思是表左边有25条记录,右边是25条记录吗?这种情况将是:

<table>
<tr>
<td>
<?php
// make sure you connected to your database
$d = mysql_query( "SELECT FROM `mytable` ORDER BY id DESC" )
$numRows = mysql_num_rows($d);
for ($count = 1; $count <= $numRows; $count ++){
$c = mysql_fetch_array($d);
$od = false;
if ($count < 25 && $od == false){

}else{
$od = true;
?>
</td><td>
<?php
}
?>
<li>
<a href='datasheets/shielded/".$c['Link']."' class='tt'/>".$c['P/N']."<span          class='tooltip'><span class='top'></span><span class='middle'>
<strong>".$c['Description']."</strong><br />
".$c['Min L']."".$c['Min L Val']." to ".$c['Max L']."".$c['Max L Value']."<br />
<strong>DCR(".$c['DCR Val']."):</strong> ".$c['Min DCR']." to ".$c['Max DCR']."<br />
<strong>Rated DC (".$c['DC Val']."):</strong> ".$c['Min DC']." to ".$c['Max DC']."<br />
".$c['Other Info']."</span><span class='bottom'></span></span></a>
</li>
<?php
}
?>
</tr>
</table>

如果这不是您不想要的答案,请尝试以不同的方式解释:)希望它有所帮助。