1

我试图让它查看 mysql 行,如果行左相等,则绘制此表。

块具有以下内容: id, title, file,side


$queryblocks = mysql_query("SELECT * FROM blocks ORDER BY id") or die(mysql_error());
while($data = mysql_fetch_array($queryblocks)) {

//select blocks
$blocktitle = $data["title"];
$blockcontent = $data["file"];
$blockside = $data["side"];
}

if($blockside = "Left"){
//START LEFT BLOCKS
echo "<table bgcolor=\"#141414\" width=\"150\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" valign=\"left\">
<tr>
<td width=\"150\" height=\"22\" background=\"cpstyles/TeamofGoD/sidebar.gif\"><center><font color=\"#ffffff\">$blocktitle</font><center>
</td>
</tr>
<tr>
<td width=\"150\" background=\"cpstyles/TeamofGoD/block-bg.gif\"><center>$blockcontent</center>
</tr>
<tr>
<td width=\"150\"><center><img src=\"cpstyles/TeamofGoD/sidebar2.gif\"></center></td>
</tr>
</table><br>";
}
4

2 回答 2

0

尝试这个:

while($data = mysql_fetch_array($queryblocks)) {

//select blocks
$blocktitle = $data["title"];
$blockcontent = $data["file"];
$blockside = $data["side"];

if($blockside = "Left"){
//START LEFT BLOCKS
echo "<table bgcolor=\"#141414\" width=\"150\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" valign=\"left\">
<tr>
<td width=\"150\" height=\"22\" background=\"cpstyles/TeamofGoD/sidebar.gif\"><center><font color=\"#ffffff\">$blocktitle</font><center>
</td>
</tr>
<tr>
<td width=\"150\" background=\"cpstyles/TeamofGoD/block-bg.gif\"><center>$blockcontent</center>
</tr>
<tr>
<td width=\"150\"><center><img src=\"cpstyles/TeamofGoD/sidebar2.gif\"></center></td>
</tr>
</table><br>";
}
}
于 2013-01-23T06:06:42.360 回答
0

您需要将条件和表格代码放入 while 循环中。或者您可以只在条件和循环之间来回跳转/转到部分,这有点难看。

于 2013-01-23T06:11:23.097 回答