Reply to Re: New problem for Newbie

Your name:

Reply:


Posted by jsd219 on 06/14/07 20:38

On Jun 14, 3:24 pm, jsd219 <i...@musiclanerecording.com> wrote:
> On Jun 14, 2:50 pm, ZeldorBlat <zeldorb...@gmail.com> wrote:
>
>
>
> > jsd219 wrote:
> > > On Jun 14, 12:31 pm, ZeldorBlat <zeldorb...@gmail.com> wrote:
> > > > On Jun 14, 12:23 pm, jsd219 <i...@musiclanerecording.com> wrote:
>
> > > > > here is my code:
>
> > > > > $query = "SELECT SEC_TITLE
> > > > > FROM section
> > > > > WHERE SEC_TITLE != ''";
>
> > > > > $result = mysql_query($query);
>
> > > > > echo "<form action='#'>\r\n<select name='section'>\r\n";
> > > > > while ($row = mysql_fetch_array($result, MYSQL_NUM))
> > > > > {
> > > > > echo " <option value='{$section[0]}'>$row[0]\r\n";
>
> > > > > }
>
> > > > > It works great but I need it to also select the ID from the section
> > > > > table without displaying it. so the client only sees a drop down box
> > > > > with the section titles but when they select one and send the form it
> > > > > will send both the section title and sec id
>
> > > > > I have tried changing the SELECT SEC_TITLE to SELECT SEC_TITLE, SEC_ID
> > > > > but i am lost from there.
>
> > > > > Anyone please :-)
>
> > > > > God bless
> > > > > jason
>
> > > > Change your query as you described above, then replace section[0] (not
> > > > sure what that was anyway) with row[1].
>
> > > Actually turns out the above code was not working properly. it needs
> > > to be this:
>
> > > $query = "SELECT SEC_TITLE
> > > FROM section
> > > WHERE SEC_TITLE != ''";
>
> > > $result = mysql_query($query);
>
> > > echo "<form action='#'>\r\n<select name=section>\r\n";
> > > while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
> > > $section = $line[0];
>
> > > echo " <option value=$section>$section\r\n";
> > > }
>
> > > This allows the client to select a section from a dynamically
> > > generated drop down box, when they submit the form whatever section
> > > they selected get placed in the section field of the new row in the
> > > category table. i need the ids from the section table to be the same
> > > as the corresponding categories added. so if i create a section called
> > > Jack and it has an (auto increment) id of 1. And then i create a
> > > category called Jack's Pale by selecting Jack from my drop down box.
> > > My category table should populate a row with the CAT_TITLE=Jack's
> > > Pale, CAT_SECTION=Jack and CAT_ID=1
>
> > > Everything is working except i can not figure out how to grab the
> > > SEC_ID and send it along with the SEC_TITLE
>
> > You want the SEC_ID as the "value" attribute, and the SEC_TITLE
> > between the <option> tags. So, you're already got the SEC_TITLE out
> > into the variable called $section:
>
> > $section = $line[0];
>
> > So now you want the id:
>
> > $id = $line[1];
>
> > And you adjust your echo as follows:
>
> > echo "<option value=$id>$section\r\n";
>
> > And, BTW, you technically need (read: you should) have double quotes
> > around $id. So something like this:
>
> > echo "<option value=\"$id\">$section\r\n";
>
> OK, here is where i am at:
>
> $query = "SELECT SEC_TITLE, SEC_ID
> FROM section
> WHERE SEC_TITLE != ''";
>
> $result = mysql_query($query);
>
> echo "<form action='#'>\r\n<select name=section>\r\n";
> while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
> $section = $line[0];
> $id = $line[1];
>
> echo " <option value=\"$section\">$section\r\n";
>
> This obviously takes care of my section but i need to include without
> the client seeing the id. I need to make it so when you select a name
> it provides both the name=section and name=id for my form. i know this
> is probably very simple but how to i keep the id hidden but send it
> with the section to the category table?
>
> many thanks
>
> God bless
> jason

take special note of ...name=section name=id... and ...value=
\"$section\"\"$id\">$section... i know both of these are completely
wrong, i am just hoping this well give you a visual of what i am
trying to do.

echo "<form action='#'>\r\n<select name=section name=id>\r\n";
while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
$section = $line[0];
$id = $line[1];

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

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

[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

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