PDA

View Full Version : Layout problem...I want a textfield in between the loop result.


rogerzebra
03-31-2005, 12:06 AM
Hi guys,

I'm stuck with a layout problem. I really can't figure this out, so all help would be appreciated. I fetching data from a while loop into rows and cells and wondering if it's possible to split up the result? I want textfield in between certain retrieved data. What I need is to know how to fetch parts of the data. Something like split the $result string in arrays and view the result arrays within tables and cells. Now I retrieve the hole chunk of data and can't sqeeze in textfields between the loop result. I need it to be in a nice layout for print.
I appreciate all effort.
/rz


$total_rows = mysql_num_rows($result);

if (!$total_rows) {
print "<HTML><BODY><h1>Table $submissions is empty</h1></BODY></HTML>";
return;
}

$row = mysql_fetch_row($result);
$total_cols = count($row);

print "<HTML><BODY>";
print "<table width='100%' border='1' cellspacing='0' cellpadding='0' align='center' bgcolor='CFB9B9'>";
print "<tr><td colspan=$total_cols align=center><strong><font size='2'><font color='F2F2F2'><br>$name Table (rows: $total_rows, column: $total_cols)</font></font></strong></td></tr>";
echo "<table border=.5>\n";
echo "<tr><td><b>Producer Code</b></td><td><b>Producer</b></td><td><b>Address</b></td><td><b>Phone Number</b></td><td><b>Fax Number</b></td><td><b>Zip Code</b></td><td><b>Contacts 1</b></td><td><b>Contacts 2</b></td><td><b>Email Address</b></td><td><b>www Address</b></td><td><b>Fein</b></td></tr>\n";

print "<tr>";
$i=0;
// Loop
while($i < $total_cols)
{
print "<td>";
print $row[$i];
print "</td>";
$i++;
}
print "</tr>";
while($row = mysql_fetch_row ($result))
{
$i = 0;
print "<tr>";
while($i < $total_cols){
print "<td>";
print $row[$i];
print "</td>";
$i++;
}
print "</tr>";
}
print "</TABLE></BODY></HTML>";

Tangerine Dream
03-31-2005, 01:36 AM
Hi, check mysql_fetch_assoc (http://www.php.net/manual/en/function.mysql-fetch-assoc.php) and mysql_fetch_array (http://www.php.net/manual/en/function.mysql-fetch-array.php) functions. It's hardly to write PHP code without particular example of table filled with some data and formatting

rogerzebra
04-05-2005, 12:55 AM
Tangerine Dream,
Sorry, I took a couple of days off. Thanks for your respond anyway, as you said that worked better. I got it to work using several queries instead of just one. I don't know though if that is the best way solving it?
Thank again I really appreciate it.
/rz