results from same mySQL query in multiple table columns
| From: | chk | Date: | Sun, 27 Aug 2000 17:18:48 +0000 |
| Subject: | results from same mySQL query in multiple table columns | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-13847@lists.php.net to get a copy of this message | ||
My first post to the list and newbie.
I'm trying to nicely format in 6 columns the result of a mySQL query.
My table will always have less than 72 names but right now it has 59 names.
When I apply the script below it chops off a name on the first column if I have less
than 60 names in the table and formats ok if I have 60.
Does anyone have a nice script that will count the number of items and format them
across multiple columns with out missing any?
Thank you.
Chuck
___________________________________________________
<php
$sql = "SELECT fname FROM people ORDER BY fname ASC";
$sql_result = mysql_query($sql,$connection);
echo "<table width=625 border=0 align=center>
<tr>
<th>column1</th>
<th>column2</th>
<th>column3</th>
<th>column4</th>
<th>column5</th>
<th>column6</th>
</tr>";
$all_fname = mysql_fetch_array($sql_result);
while ($column1 = array_slice($all_fname, 0, 11))["column1"]; {
$column2 = array_slice($all_fname, 12, 23)["column2"],
$column3 = array_slice($all_fname, 24, 35)["column3"],
$column4 = array_slice($all_fname, 36, 47)["column4"],
$column5 = array_slice($all_fname, 48, 59)["column5"],
$column6 = array_slice($all_fname, 60, 71)["column6"];
echo "<tr>
<td><input type=radio name=$fname value=$fname>$column1</td>
<td><input type=radio name=$fname value=$fname>$column2</td>
<td><input type=radio name=$fname value=$fname>$column3</td>
<td><input type=radio name=$fname value=$fname>$column4</td>
<td><input type=radio name=$fname value=$fname>$column5</td>
<td><input type=radio name=$fname value=$fname>$column6</td>
</tr>
}";
echo "</TABLE>";
// free resources and close connection
mysql_free_result($sql_result);
mysql_close($connection);
?>