php - How do I make this loop once, break then continue the loop? -


i looping div horizontally float:left , works way should problem each div has unique height influenced content contained within, result can messy looking when browser re sized. php loop once, break, start new row looks same no matter how browser sized.

if it's not obvious, not php , struggled piece have.

<?php $url = "xml.php"; $xml = simplexml_load_file($url); $namespaces = $xml->getnamespaces(true); // namespaces for($i = 0; $i < 10; $i++){      $poster = $xml->channel->item[$i]->children($namespaces['x'])->poster;     $html .= "<div class='wrapper' style='float:left;'>$poster</div>";}  echo $html; ?> 

if understand want information have here suggest:

your loop fine. lets want same no mater size of page. exemple : want 5 div on each row. use css it.

you have total of 10 div need 2 rows.

add loop :

if($i = 5){ $html .= "<div class='wrapper' style='float:left;clear:right;'>$poster</div>";} } else{ $html .= "<div class='wrapper' style='float:left'>$poster</div>";} } 

this basic, clear:right; css statement prevent other div go right of fifth div start new row;

you should add display:inline-block; css well.

if isnt working way want, other option ta make each row inside div same kind of if condition

exemple:

html.= '<div class="row">'; // start row here  if($i = 5){  // might want use increment keep track of row  //  because in case make 2 rows.     $html .= '</div><div class="row">'; // end first row , start new 1     }     else{     // nothing     } html.= '</div>'; //end row here 

you might want use second increment jump 5 bit of mat can make like

after have tweak css row class.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -