Jump to content


Photo

creating colums in PHP


  • Please log in to reply
3 replies to this topic

#1 cheyner11

cheyner11
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationCalgary, Alberta, Canada

Posted 15 March 2006 - 06:13 AM

I need some help columizing data into three rows.

what would the PHP code be to create a data print like the following:

data A | data B | data C

Thanks for your help

#2 greycap

greycap
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 15 March 2006 - 08:28 AM

[!--quoteo(post=355235:date=Mar 15 2006, 12:13 AM:name=cheyner11)--][div class=\'quotetop\']QUOTE(cheyner11 @ Mar 15 2006, 12:13 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I need some help columizing data into three rows.

what would the PHP code be to create a data print like the following:

data A | data B | data C

Thanks for your help
[/quote]

<?php

$sql = "SELECT a, b, c FROM T";

$result = mysql_query($sql) or die(mysql_error());

print "<table>";
while ($row = mysql_fetch_assoc($result) 
   print "<tr><td> $row['a'] </td><td> $row['b'] </td> <td> $row['c']</td></tr>";

print "</table>";
?>


#3 keeB

keeB
  • Staff Alumni
  • Advanced Member
  • 1,078 posts
  • LocationCalifornia

Posted 15 March 2006 - 08:44 AM

.. Not nearly enough info on what you need to have done..

Here you go?

$x = "hi"; 
$y = "to";
$z = "you";

print "$x | $y | $z";

Come visit my site to see my latest projects
http://nick.stinemates.org/wordpress/


#4 cheyner11

cheyner11
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationCalgary, Alberta, Canada

Posted 17 March 2006 - 04:33 AM

sorry. I mean that I need the data to be columnized into three rows, whereas there is no limit to the amount of data. So if there were 8 rows in a database, I would need it to print:

Row 1 | Row 2 | Row 3
Row 4 | Row 5 | Row 6
Row 7 | Row 8






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users