|
Posted by Steve Wright on 04/16/07 17:47
In message <nSMUh.1$PA6.0@newsfe04.lga>, Steve <no.one@example.com>
writes
>"dangerd" <duncanelliot@breathe.com> wrote in message
>news:1176737155.703447.58140@n59g2000hsh.googlegroups.com...
>| Hi folks,
>|
>| can someone help me understand the meaning behind this snippet of
>| code:
>|
>| $result = mysql_query('SELECT category_id,category_name FROM
>| gallery_category');
>| while($row = mysql_fetch_array($result)) {
>| $photo_category_list .= <<<__HTML_END
>| <option value="$row[0]">$row[1]</option>\n
>| __HTML_END;
>| }
>|
>| I start to get confuse when the .=<<<_HTML_END bit start, how does
>| this work? I don't understand.
>|
>| Thanks
>
>it's called a heredoc. i hate them, but others love them. essentially you
>are breaking out of php code so that what is contained inbetween <<<__TAG
>and __TAG can be written as if it were literal text. it is much more clear
>to me to do:
>
>$photo_category_list .= '<option value="' . $row[0] . '">' .
> $row[1] .
> "</option>\n";
>
>but that's just me.
>
>btw, wouldn't it make much more sense to make $row be $columns since the key
>of the array points to a column/field and not a row of data?
>
>
Better still
$photo_category_list .= '<option value="' .
$row['category_id'] . '">' .
$row['category_name'] .
'</option>\n";
--
Steve Wright
Navigation:
[Reply to this message]
|