English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have a mysql table of tablename names with two fields ID and NAME. I have so many entries in that table, I want to display three names in one line.

example:

name1-name2-name3
name4-name5-name6
name7-name8-name9
and more....

anybody can give idea?

2006-07-02 03:41:40 · 2 answers · asked by Mohammad Shahid 1 in Computers & Internet Programming & Design

2 answers

sql statement - "SELECT name FROM table"

//run the sql statement, changes if you are using PDO or another abstraction layer (recommended)
$count=0;
while($rs = fetchRow()){
if($count > 0){echo " - ";}
echo $rs['name'];
if($count==2){
echo "
";
$count=0;
}
}
?>

2006-07-02 03:49:05 · answer #1 · answered by John J 6 · 0 0

$count = 0;
while(++$count%3)
while(fetch data here)
echo here ;

2006-07-02 20:02:06 · answer #2 · answered by Spitrabergâ?¢ 4 · 0 0

fedest.com, questions and answers