Thamaraiselvam
Thamaraiselvam

Reputation: 7080

Cannot start with new line in html

if(!empty($interest)){

foreach ($interest as $key => $value) {
    echo "<div style='float:left; height:130px; width:100px; margin-left:10px; border:solid #f8f8f8; background-color: #f8f8f8;'>";
    echo   "<a class='avatar' href='#'><img width='90' height='40' src=".$value['item_image']."></a>";
        echo   "<div><i>".$value['item_name']."</i></div>";
     echo  "<a href='#' style='text-decoration: none; outline: none;'><span class='label label-success' value=".$value['item_id']." id=".$value['item_id']." onClick='reply_click1(this.id)'>Added</span></a>";
       echo " </div>";


        }
}

this is my code I'm printing images horizontally here but i need to print two images per line ! this is my output . enter image description here

I need two items per row

enter image description here

i tried to put <hr> and <br> it did not help me ! is there any way to do this?

Upvotes: 1

Views: 70

Answers (3)

priya786
priya786

Reputation: 1834

easy way to define your div width:50% in style or use clear:both in br

Upvotes: 1

Mihir Bhatt
Mihir Bhatt

Reputation: 3155

$counter = 0;
foreach ($interest as $key => $value) {

$counter++;

if($counter%2==0){
  echo '<div style="clear:both;"></div>';
}

echo "<div style='float:left; height:130px; width:100px; margin-left:10px; border:solid #f8f8f8; background-color: #f8f8f8;'>";
echo   "<a class='avatar' href='#'><img width='90' height='40' src=".$value['item_image']."></a>";
    echo   "<div><i>".$value['item_name']."</i></div>";
 echo  "<a href='#' style='text-decoration: none; outline: none;'><span class='label label-success' value=".$value['item_id']." id=".$value['item_id']." onClick='reply_click1(this.id)'>Added</span></a>";
   echo " </div>";


    }
}

Upvotes: 3

Tommaso Bertoni
Tommaso Bertoni

Reputation: 2381

Because you have float:left css property, you must write a <br style="clear:both" />

Upvotes: 1

Related Questions