Line break in Firefox but not in IE..help!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
REwingUK
Forum Commoner
Posts: 26
Joined: Wed Jul 29, 2009 8:46 pm

Line break in Firefox but not in IE..help!

Post by REwingUK »

This Code basically displays images side by side, then after 2 images it will break to a new line, so on and so on...

It looks fine in Firefox but in IE will produce just image after image without break. Any help would be great!

Regards

Code: Select all

 
    $node = new sqlNode();
    $node->select = "*";
    $node->table = "members";
    $node->orderby = "order by Rand() ";
    
    if(($adsRS = $mysql->select($node)) === false )
        die($mysql->debugPrint($node));
        
    $num_ads = mysql_num_rows($adsRS);
    
    $count = 0;
    $break = ceil($num_ads/2);
        
?>
 
    <?
    //For each ad
        while( $memberRow = mysql_fetch_assoc($adsRS) ){
        $logoLocation = $memberRow['logo'];
        if($logoLocation != ''){
        echo "<a href='agencies.php?mID=".$memberRow['ID']."'>";
        echo "<img src='admin/photos/uploads/logos/".$memberRow['logo']."' class='agentlogos' title='View Properties' border=1 width='100' />";
        echo "</a>";
                }
        if($count == $break) {
        $count++;
        }
        }
    ?>
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Line break in Firefox but not in IE..help!

Post by requinix »

Post HTML.

I don't see any kind of "break" in there. No <p>, no <br>...
REwingUK
Forum Commoner
Posts: 26
Joined: Wed Jul 29, 2009 8:46 pm

Re: Line break in Firefox but not in IE..help!

Post by REwingUK »

Even with the br tag in there, still IE produces one straight line of images.

Code: Select all

<?
    if(ereg("advertisements.php",$_SERVER['PHP_SELF'])){
        @header("Location:index.php");
        die("<script>window.location='index.php';</script>"); //js redirect backup
    }
    
    //Fetch advertisements
    $node = new sqlNode();
    $node->select = "*";
    $node->table = "members";
    $node->orderby = "order by Rand() ";
    
    if(($adsRS = $mysql->select($node)) === false )
        die($mysql->debugPrint($node));
        
    $num_ads = mysql_num_rows($adsRS);
    
    $count = 0;
    $break = ceil($num_ads/2);
        
?>
 
    <?
    //For each ad
        while( $memberRow = mysql_fetch_assoc($adsRS) ){
        $logoLocation = $memberRow['logo'];
        if($logoLocation != ''){
        echo "<a href='agencies.php?mID=".$memberRow['ID']."'>";
        echo "<img src='admin/photos/uploads/logos/".$memberRow['logo']."' class='agentlogos' title='View Properties' border=1 width='100' />";
        echo "</a>";
                }
        if($count == $break) {
        $count++;
        }
        echo "</br>";
        }
    ?>
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Line break in Firefox but not in IE..help!

Post by requinix »

That doesn't look like a <br> to me.
REwingUK
Forum Commoner
Posts: 26
Joined: Wed Jul 29, 2009 8:46 pm

Re: Line break in Firefox but not in IE..help!

Post by REwingUK »

My mistake, this now breaks after each image, how can i modify the code so it breaks after every 2 images.

Regards

Code: Select all

<?
    if(ereg("advertisements.php",$_SERVER['PHP_SELF'])){
        @header("Location:index.php");
        die("<script>window.location='index.php';</script>"); //js redirect backup
    }
    
    //Fetch advertisements
    $node = new sqlNode();
    $node->select = "*";
    $node->table = "members";
    $node->orderby = "order by Rand() ";
    
    if(($adsRS = $mysql->select($node)) === false )
        die($mysql->debugPrint($node));
        
    $num_ads = mysql_num_rows($adsRS);
    
    $count = 0;
    $break = ceil($num_ads/2);
        
?>
 
    <?
    //For each ad
        while( $memberRow = mysql_fetch_assoc($adsRS) ){
        $logoLocation = $memberRow['logo'];
        if($logoLocation != ''){
        echo "<a href='agencies.php?mID=".$memberRow['ID']."'>";
        echo "<img src='admin/photos/uploads/logos/".$memberRow['logo']."' class='agentlogos' title='View Properties' border=1 width='100' />";
        echo "</a>";
                }
        if($count == $break) {
        $count++;
        }
        if($count == $break) {
        $count++;
        }
        echo "<br>";
        }
    ?>
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Line break in Firefox but not in IE..help!

Post by requinix »

Keep a counter running that keeps track of how many images it's been through. If that number is a multiple of two then write a break.

Or keep a different counter that tells you what "column" you're in. When you reach the furthest column (#2) reset it and write a break.

Or keep a true/false value that starts with true. In the loop flip the value (true<->false) and when it's true write a break.

Or do it one of a billion other ways.
Post Reply