...

View Full Version : looping problem



mhunt
07-24-2007, 04:11 PM
The point of this is to list a companies info, and then list the type of company categories it belongs to. that's why the if statement is there.
But it's only listing one category and then showing the next business, then showing the first business again and listing the second company type and i can't figure out why it's skipping over the second category.


$b_id = "";

while($row = $db->fetchArray($res)) {
if($row['b_id'] != $b_id ) {
$b_id = $row['b_id'];
?>
<hr />
<?
$desc = $row['b_desc'];
if($row['b_image']) { ?><img src="../images/thumb/<? echo $row['b_image']; ?>" alt="<? echo $row['b_title']; ?>" /><br /><? }
?>
<a href="edit.php?action=business&amp;id=<? echo $row['b_id']; ?>">Edit</a> / <a href="#" onclick="confirmDelete('business','<? echo $row['b_id']; ?>');">Delete</a> / <a href="../b_info.php?id=<? echo $row['b_id']; ?>">Preview</a><br />
<strong>Title:</strong> <? echo $row['b_title']; ?> <br />
<strong>Address:</strong> <? echo $row['b_address1']; ?><br /><? if($row['b_address2']) { echo $row['b_address2']."<br />"; } echo $row['b_city'].", ".$row['b_state']." ".$row['b_zip']."<br />"; ?>
<strong>Phone: </strong> <? echo $row['b_phone']; ?><br />
<? if($row['b_fax'] == "") { } else { echo "<strong>Fax: </strong>".$row['b_fax']."<br />"; } ?>
<? if($row['b_email'] == "") { } else { echo "<strong>Email: </strong>".$row['b_email']."<br />"; } ?>
<? if($row['b_weburl'] == "") { } else { echo "<strong>Website: </strong> <a href=".$row['b_weburl'].">".$row['b_weburl']."</a><br />"; } ?>
<strong>Description:</strong><br /> <? echo $desc; ?><br />
<em>Also found in:</em><br />
<?
}
echo htmlspecialchars($row['t_name'])."<br />";
}

mlseim
07-24-2007, 04:35 PM
This is hard without testing it, but I think it's a misplaced bracket ...



<a href="edit.php?action=business&amp;id=<? echo $row['b_id']; ?>">Edit</a> / <a href="#" onclick="confirmDelete('business','<? echo $row['b_id']; ?>');">Delete</a> / <a href="../b_info.php?id=<? echo $row['b_id']; ?>">Preview</a><br />
<strong>Title:</strong> <? echo $row['b_title']; ?> <br />
<strong>Address:</strong> <? echo $row['b_address1']; ?>
<br />
<?
if($row['b_address2']) {
echo $row['b_address2']."<br />";
echo $row['b_city'].", ".$row['b_state']." ".$row['b_zip']."<br />";
}
?>
<strong>Phone: </strong> <? echo $row['b_phone']; ?><br />
<? if($row['b_fax'] == "") { } else { echo "<strong>Fax: </strong>".$row['b_fax']."<br />"; } ?>
<? if($row['b_email'] == "") { } else { echo "<strong>Email: </strong>".$row['b_email']."<br />"; } ?>
<? if($row['b_weburl'] == "") { } else { echo "<strong>Website: </strong> <a href=".$row['b_weburl'].">".$row['b_weburl']."</a><br />"; } ?>
<strong>Description:</strong><br /> <? echo $desc; ?><br />
<em>Also found in:</em><br />

mhunt
07-24-2007, 04:39 PM
nah i want it to show the b_city and stuff, only if the b_address2 is there then show the b_address2



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum