473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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 928

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

Similar topics

32
by: Rich | last post by:
I'm sure it sounds kinda nutty to display 200 columns and 500,000 rows of data. But I have been pulling data from a Lotus Notes database into Sql Server for a while now, but Lotus Notes is...
2
by: mary | last post by:
I need to display 10 fields (columns) to display in a crystal Report. When I am trying to print the report some of the columns are cutting off from the report. Is there any way to display the...
2
by: Ross Hamilton | last post by:
Can anyone help me with this small problem. I have a report that is divided into 3 Columns using the page setup, It displays the report fields in 3 separate columns (Desc & Pg Num) but it only...
3
by: Diego TERCERO | last post by:
Hi... I'm working on a tool for editing text resources for a family of software product my company produces. These text resources are found in a SQL Server database, in a table called...
2
by: Erik Cruz | last post by:
Hi. I have a repeater control bound to an ArrayList. When displaying the data, I need to show 3 columns per row, each column being one entry of my ArrayList, but the repeater understands that...
1
by: Kiran A K | last post by:
Hi, I have a web service that returns a DataSet object. Now i want to write a client app that consumes this web service. In my client, i want to display the rows and columns of the DataSet...
0
by: Greg Collins [Microsoft MVP] | last post by:
I have written and posted the following articles which will prove useful to some: Display Lists in Columns Horizontally Using One Cell per Column...
1
by: =?Utf-8?B?bmlr?= | last post by:
I recently noticed that all folders across my computer (XP SP2) now include the artist, album title, track no. and year columns, as if the folder contains music. I don't want to have to go through...
5
by: rui dias | last post by:
Hello, I have a (big) table which is not normalized, but for i need at the moment i think that's no problem. Indeed, what i would like to do is to select the name field and the note. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.