iam create website use template, but i'm confused while loop / for loop one of script this template
this loop 2 div but only contain 2 content/article/news
This screenshot
http://i.stack.imgur.com/0OHsV.png
This code
<?php
$data_news = mysql_query("select * from news");
while($news=mysql_fetch_object($data_news)){
?>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<ul>
<li class="clearfix">
<div class="scale_image_container">
<a href="#"><img src="images/flex_small_img1.jpg" alt="" class="scale_image"></a>
</div>
<div class="post_text">
<a href="#"><h4><?php echo $news->title ?></h4></a>
<div class="event_date"><?php echo tgl($news->datenews) ?></div>
</div>
</li>
<li class="clearfix">
<div class="scale_image_container">
<a href="#"><img src="images/img1.jpg" alt="" class="scale_image"></a>
</div>
<div class="post_text">
<a href="#"><h4><?php echo $news->title ?></h4></a>
<div class="event_date"><?php echo tgl($news->datenews) ?></div>
</div>
</li>
</ul>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<ul>
<li class="clearfix">
<div class="scale_image_container">
<a href="#"><img src="images/flex_small_img1.jpg" alt="" class="scale_image"></a>
</div>
<div class="post_text">
<a href="#"><h4><?php echo $news->title ?></h4></a>
<div class="event_date"><?php echo tgl($news->datenews) ?></div>
</div>
</li>
<li class="clearfix">
<div class="scale_image_container">
<a href="#"><img src="images/img1.jpg" alt="" class="scale_image"></a>
</div>
<div class="post_text">
<a href="#"><h4><?php echo $news->title ?></h4></a>
<div class="event_date"><?php echo tgl($news->datenews) ?></div>
</div>
</li>
</ul>
</div>
<?php } ?>
How i can while loop/for loop like my this screenshot ?
Thank's :)
1you can use something like this , please try
<?php
$data_news = mysql_query("select * from news");
$count=1;
while($news=mysql_fetch_object($data_news)){
?>
<?php if($count % 2!=0 ) {?>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<ul>
<?php } ?>
<li class="clearfix">
<div class="scale_image_container">
<a href="#"><img src="images/flex_small_img1.jpg" alt="" class="scale_image"></a>
</div>
<div class="post_text">
<a href="#"><h4><?php echo $news->title ?></h4></a>
<div class="event_date"><?php echo tgl($news->datenews) ?></div>
</div>
</li>
<?php if($count % 2==0) {?>
</ul></div>
<?php } ?>
<?php $count++;} ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.