Re: Table Making
| From: | Analysis & Solutions | Date: | Thu, 11 Jul 2002 15:14:51 +0000 |
| Subject: | Re: Table Making | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-107150@lists.php.net to get a copy of this message | ||
On Thu, Jul 11, 2002 at 03:14:07PM +0200, joakim.andersson@cybercom.se wrote:
>
> Another way of doing it is to use mysql_data_seek() to jump back and forth
> in the result set.
Now that Jason clarified what he's trying to do, Joakim is on target.
Since this data set already exists, I'd do this rather than create another
data set in an array. Trick is, how...
$Columns = 5;
$Rows = ceil( mysql_row_count($Result) / $Columns );
echo "<table border=\"1\">\n";
for ($RowCounter = 0; $RowCounter < $Rows; $RowCounter++) {
echo " <tr>\n";
for ($ColCounter = 0; $ColCounter < $Columns; $ColCounter++) {
$Index = ($Rows * $ColCounter) + $RowCounter;
echo ' <td>';
if ( mysql_fetch_seek($Result, $Index) ) {
$row = mysql_fetch_row($Result);
echo $row[0];
} else {
echo ' ';
}
}
echo " </tr>\n";
}
echo "</table>\n\n";
This stuff is untested on MySQL, but I tested it with a sample array and
it works.
--Dan
--
PHP classes that make web design easier
SQL Solution | Layout Solution | Form Solution
sqlsolution.info | layoutsolution.info | formsolution.info
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409