Page 1 of 1

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

Posted: Wed Jul 29, 2009 9:36 pm
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++;
        }
        }
    ?>

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

Posted: Wed Jul 29, 2009 9:40 pm
by requinix
Post HTML.

I don't see any kind of "break" in there. No <p>, no <br>...

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

Posted: Wed Jul 29, 2009 9:43 pm
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>";
        }
    ?>

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

Posted: Wed Jul 29, 2009 10:02 pm
by requinix
That doesn't look like a <br> to me.

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

Posted: Wed Jul 29, 2009 10:12 pm
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>";
        }
    ?>

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

Posted: Wed Jul 29, 2009 11:42 pm
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.