Using echo with lists in php? -


i have following php code:

$getnews = mysql_query("select * news order id desc") or die(mysql_error()); while ($row = mysql_fetch_assoc($getnews)) {   $id = $row['id'];   $title = $row['title'];   $body = $row['body'];   $date = $row['date'];   echo "<div class=\"title\">$title</div><br>";   echo nl2br($body);   echo "<br><div class=\"date_time\">".time_ago($date)."</div>";   echo "<hr>"; } 

this used create news feed , use echo print out within updates. there way in maybe use list print out each update instead of way im doing it?

or possible create div around each update while loop creates?

i'm sorry if question not clear help!

my newsfeed creates updates in news feed twitter. each update printed out using echo , surrounded


. im trying find way in can create list or div entire layout of each update. im finding difficult arrange whats going on in each update.

the following code should there. echo out html appear.

$getnews = mysql_query("select * news order id desc") or die(mysql_error()); while ($row = mysql_fetch_assoc($getnews)) {     $id = $row['id'];     $title = $row['title'];     $body = $row['body'];     $date = $row['date'];     echo "<div class='news-article'>";     echo "<div class=\"title\">$title</div><br>";     echo nl2br($body);     echo "<br><div class=\"date_time\">".time_ago($date)."</div>";     echo "</div>";     echo "<hr>"; } 

a lot of time lot of echo statements confuse trying do.

$getnews = mysql_query("select * news order id desc") or die(mysql_error()); while ($row = mysql_fetch_assoc($getnews)) {     $id = $row['id'];     $title = $row['title'];     $body = $row['body'];     $date = $row['date'];     ?>     <div class='news-article'>     <div class="title"><?php echo $title ?></div><br>     <?php echo nl2br($body); ?>     <br><div class="date_time"><?php echo(time_ago($date)) ?></div>     </div>     <hr>     <?php } 

if wanted accomplish same thing unordered list this.

$getnews = mysql_query("select * news order id desc") or die(mysql_error()); echo "<ul class='article-list'>"; while ($row = mysql_fetch_assoc($getnews)) {     $id = $row['id'];     $title = $row['title'];     $body = $row['body'];     $date = $row['date'];     ?>     <li class='news-article'>     <div class="title">$title</div><br>     <?php echo nl2br($body); ?>     <br><div class="date_time"><?php echo(time_ago($date)) ?></div>     </li>      <?php } echo "</ul>"; 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -