Efficiency
| From: | Support @ Fourthrealm.com | Date: | Wed, 18 Sep 2002 20:41:50 +0000 |
| Subject: | Efficiency | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-116797@lists.php.net to get a copy of this message | ||
Which is more efficient?
a) a sql loop where everything is displayed/formatted using echo stmts, like this:
$result = mysql_query("SELECT * FROM news WHERE active=1");
while ($row = mysql_fetch_object($result)) {
echo "<TR><TD>$row->title </TD></TR>";} mysql_free_result($result); ?> OR b) a sql loop where you break in and out of php tags as needed: <?php $result = mysql_query("SELECT * FROM news WHERE active=1"); while ($row = mysql_fetch_object($result)) { ?> <TR><TD>
<?php echo "$row->title"; ?></TD></TR> <?php } mysql_free_result($result); ?> Obviously, these are really simplified examples. Typically the html code gets much more complicated. Peter - - - - - - - - - - - - - - - - - - - - - Fourth Realm Solutions pbechard@fourthrealm.com http://www.fourthrealm.com Tel: 519-739-1652 - - - - - - - - - - - - - - - - - - - - -