Link to home
Start Free TrialLog in
Avatar of jaxbrian
jaxbrian

asked on

Trying to print 3 columns of data from mysql with php

I am trying to print rows from a database into three columns and then be able to print them in three columns as well. the below code is what I am using to display the three columns but when I try to print them. it doesn't want to print them correctly. it only displays some of the rows in the print preview. any suggestions? I have tried creating a print CSS and force it to break on an tag but I haven't had any luck with it.
$data = mysql_query("SELECT * FROM test") ;
$data_count = mysql_num_rows($data);
$div_open = '<div style="float:left;margin-left:30px;">';
$div_close = '</div>';

print $div_open;
print "<ul>";

for ( $i = 0; i < 150 && $i < $data_count; $i ++)
{
	if ($i % 50 == 0 && $i > 1)
	{
		print $div_close;
		print $div_open;
		print "<ul>";
	}
	$info = mysql_fetch_array( $data );
	print "<tr><td>" . $info['1'] . "&nbsp;&nbsp;&nbsp;" . $info['2'] . "&nbsp;&nbsp;&nbsp;" . "</td><td>" .  $info['3'] . "</td></tr><br>";

}
print "</ul>";
print $div_close;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of MatthewP
MatthewP
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jaxbrian
jaxbrian

ASKER

will do
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok, I have it doing what I wanted it to do. it was  combination of both your answers plus some more tweaking.

thank you guys very much for your time and input
it was just one guy but ... lol