Reply to Re: New problem for Newbie

Your name:

Reply:


Posted by william.clarke on 06/16/07 02:19

On Jun 15, 7:27 am, jsd219 <i...@musiclanerecording.com> wrote:
> On Jun 14, 4:09 pm, Michael Fesser <neti...@gmx.de> wrote:
>
>
>
> > .oO(ZeldorBlat)
>
> > >And, BTW, you technically need (read: you should) have double quotes
> > >around $id. So something like this:
>
> > >echo "<option value=\"$id\">$section\r\n";
>
> > Some notes:
>
> > * Single quotes are fine as well and avoid the ugly escaping.
> > * For better code all elements should be closed, even if some end tags
> > are optional in HTML.
> > * A simple \n line ending is enough.
> > * It's usually a good idea to use htmlspecialchars() when printing HTML
> > to avoid validator warnings because of literal '&' or '<' chars.
>
> > So it should be at least
>
> > echo "<option value='$id'>$section</option>\n";
>
> > or better
>
> > printf("<option value='%u'>%s</option>\n",
> > $id,
> > htmlspecialchars($section)
> > );
>
> > For the OP:
>
> > * The form's 'action' attribute should not contain an empty URL ('#' is
> > an empty URL with an empty fragmet identifier), as some older browser
> > get it wrong.
> > * Attribute values should always be quoted (single- or double-quotes).
>
> > Micha
>
> how can i make echo "<option value='$id'>$section</option>\n"; also
> include $section?


Hi Jason,

It sounds like you do not fully understand how PHP and HTML are
interacting in your code (the links at the bottom will help but maybe
my slightly wordy explanation will too).

The code you have been given: echo "<option value='$id'>$section</
option>\n";
Puts the ID in the value (not visible to the user) attribute of the
option tag (this is what gets
sent back to the server in the GET/POST array) the SECTION will be
displayed as the text within the
visible part of the drop down list. If for some reason you want to
concatenate the ID and Section
together you can just go:

echo "<option value=\"".$id.$section."\">".$section."</option>\n";

NOTE: I have used double quotes which makes a few extra escape
characters necessary, and I'm also using the . to concatenate the
various parts of the string. This is just a personal preference thing
and there are plenty of other valid ways you can achieve the same
result.

Helpful Links
HTML Option Tag: http://www.w3schools.com/tags/tag_option.asp
mysql_fetch_array: http://au3.php.net/mysql_fetch_array


William

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация