469,934 Members | 2,692 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

Display blogs in mulitple columns.

Below is a code which gets blogs from database and displays it in single column on screen, I want to display blogs in multiple columns may be three,with each column displaying 10 blogs ordered by their id, so how to do that. If it is too long to answer here maybe mentioning any method that is easy to use can help me.

this is how I call posts from db:

Expand|Select|Wrap|Line Numbers
  1.  $query = ("SELECT blogs_id, title, body, posted_by,  category FROM blogs INNER JOIN 
  2.     categories ON categories.category_id=blogs.category_id ORDER BY blogs_id desc LIMIT 10");
  3.     foreach($db->query($query)as $row){
  4.     $blogs_id = $row['blogs_id'];
  5.     $title = $row['title'];
  6.     $body = $row['body']; 
  7.     $posted_by = $row['posted_by']; 
  8.     $full_name = $row['full_name'];  
  9.     }
  10.  
  11.     $get_user = $db->prepare("SELECT * FROM userss WHERE username= :username");
  12.     $get_user->execute(array(':username'=>$posted_by)); 
  13.     $get_row = $get_user->fetch(PDO::FETCH_ASSOC);
  14.  
  15.     $profilephoto = $get_row['profile_photo'];
  16.       if ($profilephoto_ == "") {
  17.          $profilephoto = "./img/avatar_pic.png";
  18.       }
  19.       else {
  20.          $profilephoto = "./userdata/profile_photos/".$profilephoto_info;
  21.       }
  22.  
  23.       echo "<h2>$title</h2>
  24.           <p>$body</p>
  25.          <img src='$profilephoto' height='60'><br />
  26.             By:<a href='$posted_by'>$full_name</a>"; 
Oct 11 '15 #1
0 778

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Erik Cruz | last post: by
1 post views Thread by Kiran A K | last post: by
reply views Thread by Greg Collins [Microsoft MVP] | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.