在 do wile 循环不循环时遇到了一些问题。目前在 SQL 中应该返回 2 个结果,但它只显示一个。
SQL。- 它应该找到的两个结果
array('bid'=>4,'bname'=>'fdsfsdaf','section'=>'Network','btype'=>'Activity','breq'=>'fdsfsd','bnotes'=>'fdsfdsf','image'=>'Badges/Network/2inchsquare.png'),
array('bid'=>3,'bname'=>'Test','section'=>'Network','btype'=>'Activity','breq'=>'dfsfds','bnotes'=>'fsdfs','image'=>'Badges/Network/2inchsquare.png')
);
我的 PHP
<?php
require_once('inc/global.php');
include('inc/auth.php');
mysql_select_db($dbname, $db);
$sql = "SELECT * FROM badges WHERE section = 'Network'";
$result = mysql_query($sql, $db) or die(mysql_error());
$bnetwork = mysql_fetch_assoc($result);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin</title>
<link href="css/admin.css" type="text/css" rel="stylesheet" media="screen,projection" />
</head>
<body>
<div id="listtable">
<table class="contacts">
<tr>
<td class="contactDept" width="20%">Badge Name</td>
<td class="contactDept" width="20%">Section</td>
<td class="contactDept" width="20%">Badge Type</td>
<td class="contactDept" width="20%">Pic</td>
<td class="contactDept" width="10%">Edit</td>
<td class="contactDept" width="10%">Del</td>
</tr>
</table>
<?php do { ?>
<ul>
<li class="badgeName"><?php echo $bnetwork['bname']; ?></li>
<li class="badgeSection"><?php echo $bnetwork['section']; ?></li>
<li class="badgeType"><?php echo $bnetwork['btype']; ?></li>
<li class="badgePic"><img src="<?php echo $bnetwork['image'];?>" width="30px" height="30px"></li>
<li class="badgeEdit"><a href="#">Edit</a></li>
<li class="badgeDel"><a href="#">Del</a></li>
</ul>
<?php } while($bnetwork = mysql_fetch_assoc($result)); ?>
</div>
</body>
</html>
我知道该表不应该在LI标签中,我只是在尝试以防万一它由于某些未知原因不喜欢TD标签。请告诉我你是否能弄清楚为什么它只显示一个结果。