Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: looping problem

  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts

    looping problem

    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.
    PHP Code:
    $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 />";
        }

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,538
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    This is hard without testing it, but I think it's a misplaced bracket ...

    PHP Code:
    <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 />

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nah i want it to show the b_city and stuff, only if the b_address2 is there then show the b_address2


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •