PHP simple : PHP tutorial, MySQL tutorial
PHP Tutorial - Free PHP Script

Home | Tutorials | Php vs Node.Js | Web Tools

Show Records by multi Columns in Rows

Tutorials > Show Records by multi Columns in Rows

There are simply to show data records in table rows, just one record by one table row but sometime you need to show data records more than one record in one row. This tutorial show you how can to show your data records in the table with three columns and make multi-rows automatically with while loop.

This tutorial require 1 PHP file and 1 table of mySQL database.

  1. show_multi_columns.php
  2. Database "tutorial" and table "name_list" with 2 fields: id(auto_increment), name(varchar, 50) and put some records about 20 - 30 records into this table. (directly by phpMyAdmin)


Source Code

<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

// Connect database.

// Get data records from table.
$result=mysql_query("select * from name_list order by id asc");

<table border="1">

<? echo $row['name']; ?>
<? $row=mysql_fetch_assoc($result);
// make one record out. ?>
<? echo $row['name']; ?>
<? $row=mysql_fetch_assoc($result); // make one record out. ?>

<? echo $row['name']; ?>
<? $row=mysql_fetch_assoc($result); // make one record out. ?>

} // End loops.


Put Ebay RSS Feeds onto your website
SEO Elite Software
Domain Dashboard CPanel & Seo Manager
Work at Home Ideas and Opportunities
Introduction & Get Start
Using Form
PHP Tags
PHP Variables
PHP Control Structures
Create Database & Table
Database Connection
Insert Record
Select Record
Update Record
Delete Record
[email protected]