[thelist] PHP style question..
Mark Howells
mark at mountain.ch
Tue Dec 18 11:20:04 CST 2001
That is commonplace, though many people would break the PHP flow to write
HTML to the page, then come back to PHP.
E.g.
<?
$var="value";
?>
<p>This method has some <?=$var?></p>
<?
$var="";
?>
The more common use of "echo"ing HMTL is by using the printf command in a
loop, where you're outputting a query recordset to the page.
E.g.
<?
$imageData = mysql_query($theSQL,$db);
$rowCount = mysql_num_rows($imageData);
if($rowCount){
$thisRow=0;
do {
$picPath=mysql_result($imageData,$thisRow,"picturePath");
printf("<img src=\"%s\" />\n",$picPath);
$thisRow=$thisRow+1;
} while ($thisRow < $rowCount);
}
?>
Regards
Mark Howells
Working in a Winter Wonderland
http://www.mark.ac
> Von: "Daniel J. Cody" <djc at members.evolt.org>
> Antworten an: thelist at lists.evolt.org
> Datum: Tue, 18 Dec 2001 11:04:48 -0600
> An: thelist at lists.evolt.org
> Betreff: [thelist] PHP style question..
>
> In my journey that leads to PHP godliness, I've been seeing other
> peoples code that basically echo's out the HTML parts of the PHP page:
>
> <?
> echo "<html>\n"
> ?>
>
> Is that commonplace? I find it kind of backwards and usually only put
> PHP markup *within* HTML, not around it. Am I missing something?
More information about the thelist
mailing list