Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How do i display mysql data in a 5 column 5 row table ?
Old 11-04-2008, 01:18 PM How do i display mysql data in a 5 column 5 row table ?
Novice Talker

Posts: 6
Trades: 0
Hi,

i am trying to display data from a mysql database in a HTML table in a certain way, i can get the data to display in a one column list but i require the data to display in a five column five row table, any ideas on how i can go about doing this ?

P.S. i use PHP to call the mysql data.

Thanks,
Mark H.
toasty525 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-04-2008, 01:29 PM Re: How do i display mysql data in a 5 column 5 row table ?
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
It's simple, create 5 columns and 5 rows

Think, don't stink
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 11-04-2008, 02:25 PM Re: How do i display mysql data in a 5 column 5 row table ?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
I'm in a good mood tonight, so:
PHP Code:
<?php
$html
="<table>";
$cptLine=0;
$q="select a, b, c from tbl";
$r=mysql_query($q);
while(
$o=mysql_fetch_object($r)){
  if(
$cptLine===0){
    
$html.="<tr>";
    foreach(
$o as $key=>$val){
      
$html.="<th>{$key}</th>";
    }
    
$html.="</tr>";
  }
  
$html.="<tr>";
  foreach(
$o as $key=>$val){
    
$html.="<td>{$val}</td>";
  }
  
$html.="</tr>";
  
$cptLine++;
}
$html.="</table>";

echo 
$html;
?>
Not tested, but you get the idea, at least.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 11-07-2008, 12:36 PM Re: How do i display mysql data in a 5 column 5 row table ?
Skilled Talker

Posts: 85
Name: Ilyes Rhouma
Trades: 0
Quote:
Originally Posted by tripy View Post
I'm in a good mood tonight, so:
PHP Code:
<?php
$html
="<table>";
$cptLine=0;
$q="select a, b, c from tbl";
$r=mysql_query($q);
while(
$o=mysql_fetch_object($r)){
  if(
$cptLine===0){
    
$html.="<tr>";
    foreach(
$o as $key=>$val){
      
$html.="<th>{$key}</th>";
    }
    
$html.="</tr>";
  }
  
$html.="<tr>";
  foreach(
$o as $key=>$val){
    
$html.="<td>{$val}</td>";
  }
  
$html.="</tr>";
  
$cptLine++;
}
$html.="</table>";

echo 
$html;
?>
Not tested, but you get the idea, at least.
Yes something like that, but it can be much easier !
__________________
Want a cheap and custom programmer or writer ?
Please login or register to view this content. Registration is FREE

Are you
Please login or register to view this content. Registration is FREE
? Start
Please login or register to view this content. Registration is FREE
free and earning money !
Please login or register to view this content. Registration is FREE
Ilyes is offline
Reply With Quote
View Public Profile Visit Ilyes's homepage!
 
Reply     « Reply to How do i display mysql data in a 5 column 5 row table ?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13252 seconds with 12 queries