Having a bit of trouble with a do wile loop not looping.. There are currently 2 results in the SQL that should be returned but it only shows one.
SQL. - the two results it should find
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')
);
My 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>
I know the table shouldnt be in LI tags, i was just trying just in case it didn't like TD tags for some unknown reason. Please tell me if you can work out why it only shows one result.
The while loop should be adequete. Also you don't need echo and the ';' when just displaying a variable in your HTML. You can just use an '=' to mean echo when it immediately follows an opening php tag. I hope this helps.
<? while($n = mysql_fetch_assoc($result)) { ?>
<ul>
<li class="badgeName"><?=$n['bname']?></li>
<li class="badgeSection"><?=$n['section']?></li>
<li class="badgeType"><?=$n['btype']?></li>
<li class="badgePic"><img src="<?=$n['image']?>" width="30px" height="30px"></li>
<li class="badgeEdit"><a href="#">Edit</a></li>
<li class="badgeDel"><a href="#">Del</a></li>
</ul>
<? } ?>