Re: Table display Driving me Crazy!
| From: | Justin Buist | Date: | Thu, 13 Sep 2001 20:36:44 +0000 |
| Subject: | Re: Table display Driving me Crazy! | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-12421@lists.php.net to get a copy of this message | ||
> Looking at your code for the first row (I've cleaned it up a bit to make it
> readable!):
>
> <?php
> $numcols = 5;
> for ($l = 1; $l <= $numcols; ++$l) {
> ?>
> <td width="139" class="ModNo" bordercolor="#000000">
> <?php
> echo $db->f("product_sku");
> ?>
> </td>
> <?php
> }
> ?>
>
>
> It should be pretty clear why you're getting the product just repeated 5
> times across the row.
>
> Your statement:
> echo $db->f("product_sku"); does not contain any reference to
> variables thus it's essentially a constant. As far as I can make out
> (your style of coding gives me a headache :)) the other loops suffer
> from the same problem.
The whole block is wraped in a while ($db->next_record()) { ...} loop
actually. Now, I'm not sure if the next_record() method is setting an
internal member to the current record and returning TRUE/FALSE for
success, or if it's actually supposed to be returning a row.
I'm guessing the class is simply being mis-used. The code is reasonably
logical assuming next_record() is setting an internal member variable to
the current row... doesn't look like it is though.
I know with ASP/VBScript that there's a decent performance hit when you
jump from HTML to VbScript and back again... I would imagine though not as
severe the same also happens in PHP. Rather than stop the parser, print
out something small like a "</td>" and start the parser back up it's
probably better performance wise to just use the 'echo' function (well,
keyword, I guess echo isn't a real function, print is though). Plus, it
makes your code more readable without all the <?php ?> marks everywhere.
Justin Buist
Trident Technology, Inc.
4700 60th St. SW, Suite 102
Grand Rapids, MI 49512
Ph. 616.554.2700
Fx. 616.554.3331
Mo. 616.291.2612