This is a discussion on Problem with <SELECT post > and $_POST() within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I am cross posting to comp.lang.php and alt.comp.lang.php. I am having a problem with getting ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I am cross posting to comp.lang.php and alt.comp.lang.php.
I am having a problem with getting a post from a dropdownlist off a html form. While debugging, by instruction steps, for some reason I am never get passed the isset($_POST['author_pk']) after selecting an item in the dropdownlist. I have coded a simple script to duplicate what I am trying to do, just to make sure i understand it, and that works. This is the code and has to be something simple.. <?php // // Debugging $debug = false; // // Open DB include 'library/opendb.php'; // This form uses the POST method, so process any post selections here if( isset($_POST['author_pk']) ) { echo 'Ok I have an author Primary Key'; // do whatever you need to do with the author_pk // $sqlcmd = $author_detail_select . {$_POST['author_pk']}; // $author_detail = mysql_query($sqlcmd); } // // main form query if ($debug){ $sqlcmd = $author_dropdown_select . ' ' . limit(); echo $sqlcmd; } else { $sqlcmd = $author_dropdown_select; } $result = mysql_query($sqlcmd); if (!$result) { die('Database Error: ' . mysql_error()); exit; } // // Close DB include 'library/closedb.php'; ?> /* Can't use 'PHP_SELF' under PHP Designer. Works running off server. <FORM NAME="author" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> */ <FORM NAME="author" method="post" action="PeopleQuotes.php"> <SELECT NAME="author_pk" SIZE="20" COLS="20"> <?php // a loop to populate the select options while( $row = mysql_fetch_object($result) ) { printf("<option value=\"%d\">%s %s, %s %s %s</option>\n", $row->id, $row->TITLE, $row->lastname, $row->firstname, $row->middlename, $row->SUFFIX); } mysql_free_result($result); // display any author details based on the user's selection if( isset($author_detail) ) { // while( $row = mysql_fetch_assoc($author_detail) ) { // printf("Title: %s<br>\n", $row['title']); } } ?> </SELECT> </FORM> Thanks in Advance... IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us __________________________________________________ ________________________ 'If there is one, Knowledge is the "Fountain of Youth"' -William E. Taylor, Regular Guy (1952-) |
|
|||
|
> I have coded a simple script to duplicate what I am trying to do, just
> to make sure i understand it, and that works. This is the code and has > to be something simple.. Maybe a stupid question, but how do you submit your choice? I don't see a submit button in your form and neither a javascript call to submit the form automatically after selecting an item from the picklist. Peter. -- http://www.phpforums.nl |
|
|||
|
IchBin wrote:
> I am cross posting to comp.lang.php and alt.comp.lang.php. > > I am having a problem with getting a post from a dropdownlist off a > html form. While debugging, by instruction steps, for some reason I > am never get passed the isset($_POST['author_pk']) after selecting an > item in the dropdownlist. .... and after a submit I assume, Peter made a good point ... print_r($_POST) and see what it containts. Grtz, -- Rik Wasmus |
|
|||
|
Rik wrote:
> IchBin wrote: >> I am cross posting to comp.lang.php and alt.comp.lang.php. >> >> I am having a problem with getting a post from a dropdownlist off a >> html form. While debugging, by instruction steps, for some reason I >> am never get passed the isset($_POST['author_pk']) after selecting an >> item in the dropdownlist. > > ... and after a submit I assume, Peter made a good point ... > > print_r($_POST) and see what it containts. > > Grtz, You guys are right.. Originally I was tying to do this with javascript and wanted to, onClick= event, post the selected field. I am use to java Objects and their events and thought I could add the logic to post the info from from the Dropdownlist and not need and submit button. I am new to php\html objects and javascript. I am a java programmer and learning your area. Some one in another thread mentioned that I could do what I wanted with just PHP. He helped me out tremendously. I am learning hour by hour. I added the submit and all is well. Thanks Guys. IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us __________________________________________________ ________________________ 'If there is one, Knowledge is the "Fountain of Youth"' -William E. Taylor, Regular Guy (1952-) |
|
|||
|
IchBin wrote:
> Rik wrote: >> IchBin wrote: >>> I am cross posting to comp.lang.php and alt.comp.lang.php. >>> >>> I am having a problem with getting a post from a dropdownlist off a >>> html form. While debugging, by instruction steps, for some reason I >>> am never get passed the isset($_POST['author_pk']) after selecting an >>> item in the dropdownlist. >> >> ... and after a submit I assume, Peter made a good point ... >> >> print_r($_POST) and see what it containts. >> >> Grtz, > > You guys are right.. Originally I was tying to do this with javascript > and wanted to, onClick= event, post the selected field. I am use to java > Objects and their events and thought I could add the logic to post the > info from from the Dropdownlist and not need and submit button. > I am new to php\html objects and javascript. I am a java programmer and > learning your area. Some one in another thread mentioned that I could do > what I wanted with just PHP. He helped me out tremendously. I am > learning hour by hour. > > I added the submit and all is well. > > Thanks Guys. > > IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us > __________________________________________________ ________________________ > > 'If there is one, Knowledge is the "Fountain of Youth"' > -William E. Taylor, Regular Guy (1952-) IchBin: You don't *have* to have a submit button. You can set the select to submit for you. i.e. <select ... onclick="submit()"> Maybe you already knew that but if you didn't it could help in your design. -david- |
|
|||
|
David Haynes wrote:
> IchBin wrote: >> Rik wrote: >>> IchBin wrote: >>>> I am cross posting to comp.lang.php and alt.comp.lang.php. >>>> >>>> I am having a problem with getting a post from a dropdownlist off a >>>> html form. While debugging, by instruction steps, for some reason I >>>> am never get passed the isset($_POST['author_pk']) after selecting an >>>> item in the dropdownlist. >>> >>> ... and after a submit I assume, Peter made a good point ... >>> >>> print_r($_POST) and see what it containts. >>> >>> Grtz, >> >> You guys are right.. Originally I was tying to do this with javascript >> and wanted to, onClick= event, post the selected field. I am use to >> java Objects and their events and thought I could add the logic to >> post the info from from the Dropdownlist and not need and submit button. >> I am new to php\html objects and javascript. I am a java programmer >> and learning your area. Some one in another thread mentioned that I >> could do what I wanted with just PHP. He helped me out tremendously. I >> am learning hour by hour. >> >> I added the submit and all is well. >> >> Thanks Guys. >> >> IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us >> __________________________________________________ ________________________ >> >> >> 'If there is one, Knowledge is the "Fountain of Youth"' >> -William E. Taylor, Regular Guy (1952-) > > IchBin: > You don't *have* to have a submit button. You can set the select to > submit for you. i.e. <select ... onclick="submit()"> > > Maybe you already knew that but if you didn't it could help in your > design. > > -david- > It is my own confusion between html and javascript. When I looked at tutorials for html the onClick was not documented. When I look at some Javascript 1.3 docs I saw a detail spec. So my assumption, before you replied to my first thread message, as that the onClick was a javascript attribute. Which now does not make sense. And yes that makes a world of difference in design. Thanks David IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us __________________________________________________ ________________________ 'If there is one, Knowledge is the "Fountain of Youth"' -William E. Taylor, Regular Guy (1952-) |