RE: RE: [PHP-DB] question on
Thanks everyone for all your help. I found some code that is using Java script and although it's not fully functional yet I am working on it. If anyone is interested here it is: .: Combobox :. <!-- select { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 7pt; font-style: normal; font-weight: bold; color: #00; background-color: #FF; height: 16px; width: 300px; border: 1px solid #00; } #left { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 7pt; font-style: normal; font-weight: bold; color: #00; background-color: #FF; text-align: right; vertical-align: middle; height: 16px; width: 150px; } #right { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 7pt; font-style: normal; font-weight: bold; color: #00; background-color: #FF; text-align: right; vertical-align: middle; height: 16px; width: 300px; } --> function getStates(what) { if (what.selectedIndex != '') { var country = what.value; document.location=('combobox.php?cSel=' + country); } } function getDistrict(what) { if (what.selectedIndex != '') { var country = document.myForm.cSelect.selectedIndex; var state = what.value; document.location=('combobox.php?cSel=' + country + '&sSel=' + state); } } function getCity(what) { if (what.selectedIndex != '') { var state = document.myForm.sSelect.selectedIndex; var district = what.value; document.location=('combobox.php?cSel=' + country + '&sSel=' + state + '&dSel=' + district); } } Select your Country: please, select your country $cNa"; } else { echo "$cNa"; } } ?> Select your State or Province: please, select your state or province $sNa, $sCu"; } else { echo "$sNa, $sCu"; } } } } ?> Select your District: please, select your district $dNa"; } } ?> Select your City: please, select your city $ctNa"; } } ?> -Original Message- From: Neil Smith [MVP, Digital media] [mailto:[EMAIL PROTECTED] Sent: Thursday, May 13, 2004 4:16 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re:RE: [PHP-DB] question on That *should* read : document.fcountry.newcountry.value = document.fcountry.country[document.fcountry.country.selectedIndex].value; Skip the 'options' object - I'm surprised you're not getting a javascript error, maybe you have error reporting turned off in your browser ? In any case, always 'alert' that value when you create it, so you know what you're actually submitting during testing. At 04:06 13/05/2004 +, you wrote: >From: "hengameh" <[EMAIL PROTECTED]> >To: <[EMAIL PROTECTED]>, > <[EMAIL PROTECTED]> >Date: Wed, 12 May 2004 12:22:20 -0400 >MIME-Version: 1.0 >Content-Type: text/plain; > charset="us-ascii" >Content-Transfer-Encoding: 7bit >Message-ID: <[EMAIL PROTECTED]> >Subject: RE: [PHP-DB] question on > > > CaptionKit http://www.captionkit.com : Production tools for accessible subtitled internet media, transcripts and searchable video. Supports Real Player, Quicktime and Windows Media Player. VideoChat with friends online, get Freshly Toasted every day at http://www.fresh-toast.net : NetMeeting solutions for a connected world. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] question on
Sorry that. I was trying to be modular! I also understand that everyone is busy and I highly appreciate any help. Anyway I cleaned it up a bit I hope its clear now ( all I am trying to do is to show a list of countries from my database and then according to the selected country make another select for the state/province and then pass all that for further search): <!-- function changeMenu(pulldown,input) { input.value = pulldown.options[pulldown.selectedIndex].value; } --> Steps 1-4 "; // // initialize or capture the country variable $country = !isset($_REQUEST['country'])? "Select a country": $_REQUEST['country']; $countrySQL = !isset($_REQUEST['country'])? "*": $_REQUEST['country']; $sretval .= "$country"; $query = "SELECT * FROM ". TABLECOUNTRY . " ORDER BY country ASC"; // pconnect, select and query if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME, DBPASSWORD)) { if ( mysql_select_db(DBNAME, $link_identifier)) { // run the query $queryResultHandle = mysql_query($query, $link_identifier) or die( mysql_error() ); $ctrRows = mysql_num_rows($queryResultHandle); // row counter // if data exists then $rows will be 1 or greater if( $ctrRows == 0 ) { $sretval .="No data found"; }else{ // build the select list while($row = mysql_fetch_object($queryResultHandle)) { // grab a row $sretval .="country\">$row->country"; } $sretval .= ""; echo $sretval; } }else{ // select echo mysql_error(); } }else{ //pconnect echo mysql_error(); } } ?> -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 12, 2004 12:41 PM To: hengameh; [EMAIL PROTECTED] Subject: RE: [PHP-DB] question on > Here is the complete code. In the one line Java script that I have I am > setting the value. So what am I missing? For the sake of the listers trying to help you, and for your own clarity of concept, I'd suggest starting out by putting all your code into one file. It's quite hard to follow as you've presented it. Also, it may make it easier if you try concatenating all your output to one $variable, then print/echoing it out. Don't mean to be difficult, but we all have our own projects to work on. dave -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] question on
Here is the complete code. In the one line Java script that I have I am setting the value. So what am I missing? Quicksearch.php file has the following code Steps 1-4 Countrty_buil.php has the following "; // // initialize or capture the country variable $country = !isset($_REQUEST['country'])? "Select a country": $_REQUEST['country']; $countrySQL = !isset($_REQUEST['country'])? "*": $_REQUEST['country']; echo "$country"; $query = "SELECT country FROM ". TABLECOUNTRY . " ORDER BY country ASC"; // pconnect, select and query if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME, DBPASSWORD)) { if ( mysql_select_db(DBNAME, $link_identifier)) { // run the query $queryResultHandle = mysql_query($query, $link_identifier) or die( mysql_error() ); $ctrRows = mysql_num_rows($queryResultHandle); // row counter // if data exists then $rows will be 1 or greater if( $ctrRows == 0 ) { echo"No data found"; }else{ // build the select list while($row = mysql_fetch_object($queryResultHandle)) { // grab a row echo "country\">$row->country"; } echo ""; } }else{ // select echo mysql_error(); } }else{ //pconnect echo mysql_error(); } ?> -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 12, 2004 12:14 PM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] question on > Thanks so much but I am so new to all this so need more explanation please. > I think at this point I don't mind the round trip to the server side till I > find a better way. But for now I think I have what you are suggesting but > then why my "echo" is not retuning anything : > > > > > Well, there is no value assgined to $_POST['newcountry'] in your example. How are you getting a value to that form field? dave -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] question on
Thanks so much but I am so new to all this so need more explanation please. I think at this point I don't mind the round trip to the server side till I find a better way. But for now I think I have what you are suggesting but then why my "echo" is not retuning anything : (country_build.php creates the select and its options) -Original Message- From: Hutchins, Richard [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 12, 2004 11:45 AM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] question on You'd have to take the value of the first select box in your form and pass it to another script. You can do that by setting the form's ACTION property to either GET or POST. Personally, I prefer POST. In the script to which you submit your form, you can access the value of the select object thusly: $_POST["varname"] and insert it into your query however you want (using the appropriate input sanitization methods). The important concept to understand here is that you cannot use PHP to drive the contents of your second select object without a round-trip to the server. Since PHP is a server-side technology, it HAS to work that way. To make a client-side solution possible, you'd have to send ALL POSSIBLE data to the page all at the same time then manipulate it with JavaScript. You can make it LOOK like a dynamic solution by repeatedly resubmitting the page to itself and using a combo platter of JS and PHP functions on the page to handle data as it is progressively requested/sent, but you're still doing a round-trip each time. It only looks like a client-side solution because you submit to the same page all the time until certain conditions are satisfied or your user clicks on a specific link or button. If you're truly in search of a completely client-side solution using JavaScript, I suggest checking the Javascript Boutique or Javascript Source or any one of the hundreds of JS repositories you'll find in a google search. There are many great examples of this problem such as selecting a State in one select box then having the major cities in that State show up in a second select object. Hope this helped. Rich > -Original Message- > From: hengameh [mailto:[EMAIL PROTECTED] > Sent: Wednesday, May 12, 2004 11:34 AM > To: 'Tony S. Wu' > Cc: [EMAIL PROTECTED] > Subject: RE: [PHP-DB] question on > > > Well I am suing Java script to capture the selected item and > make it the > value of my input box. But my problem is how to access this > information from > this point on. Can someone please tell me how I can use the > selected item in > my next SQL query? > > -Original Message- > From: Tony S. Wu [mailto:[EMAIL PROTECTED] > Sent: Wednesday, May 12, 2004 11:07 AM > To: hengameh > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] question on > > sounds like a job for JavaScript. > > Tony S. Wu > [EMAIL PROTECTED] > > "Look into the right places, you can find some good offerings." > http://homepage.mac.com/tonyswu/stw- The perfect business. > http://homepage.mac.com/tonyswu/tonyswu- My web page. > -- > -- > --- > > > > On May 12, 2004, at 7:02 AM, hengameh wrote: > > > > > > > Hello, > > > > I am very new to php and mysql so please be patient with > me. I don't > > even > > know if I am using the right listing, but I hope someone > can help me! > > > > > > > > I need to create a and the possible options are > from my mysql > > database ( so far so good, I was able to find code to do that). > > > > Now I need to use the user selected option to drive the > options of me > > next > > . I need to know how to capture what user selected > and how to > > pass > > that around? I have used "onchange" attribute of the to > > capture the > > selected line but now how can I pass that to other php > scripts? ( I > > need to > > get the name of the country so that I can show a list of possible > > state/province. I setting the value of the "newcountry" input to the > > selected "country" but when I do echo $newcountry in > quicksearch.php, > > its > > blank!!) > > > > Please help!! > > > > > > > > Thanks so much > > > > > > > > Here is what I have so far: > > > > > > > > Quicksearch.php file has the following code > > > > > > > > > > > > > > > > Steps 1-4 > > >
RE: [PHP-DB] question on
Well I am suing Java script to capture the selected item and make it the value of my input box. But my problem is how to access this information from this point on. Can someone please tell me how I can use the selected item in my next SQL query? -Original Message- From: Tony S. Wu [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 12, 2004 11:07 AM To: hengameh Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] question on sounds like a job for JavaScript. Tony S. Wu [EMAIL PROTECTED] "Look into the right places, you can find some good offerings." http://homepage.mac.com/tonyswu/stw- The perfect business. http://homepage.mac.com/tonyswu/tonyswu- My web page. --- On May 12, 2004, at 7:02 AM, hengameh wrote: > > > Hello, > > I am very new to php and mysql so please be patient with me. I don't > even > know if I am using the right listing, but I hope someone can help me! > > > > I need to create a and the possible options are from my mysql > database ( so far so good, I was able to find code to do that). > > Now I need to use the user selected option to drive the options of me > next > . I need to know how to capture what user selected and how to > pass > that around? I have used "onchange" attribute of the to > capture the > selected line but now how can I pass that to other php scripts? ( I > need to > get the name of the country so that I can show a list of possible > state/province. I setting the value of the "newcountry" input to the > selected "country" but when I do echo $newcountry in quicksearch.php, > its > blank!!) > > Please help!! > > > > Thanks so much > > > > Here is what I have so far: > > > > Quicksearch.php file has the following code > > > > > > > > Steps 1-4 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > <!-- > > function changeMenu() > > { > > document.fcountry.newcountry.value = > document.fcountry.country.options[document.fcountry.country.selectedInd > ex].v > alue; > > } > > --> > > > > > > Countrty_buil.php has the following > > > > > require_once("util.php"); > > > > echo " onchange=\"changeMenu()\">"; > > // > > // initialize or capture the country variable > > $country = !isset($_REQUEST['country'])? "Select a country": > $_REQUEST['country']; > > $countrySQL = !isset($_REQUEST['country'])? "*": $_REQUEST['country']; > > echo "$country"; > > $query = "SELECT country FROM ". TABLECOUNTRY . " ORDER BY country > ASC"; > > // pconnect, select and query > > if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME, > DBPASSWORD)) > { > > if ( mysql_select_db(DBNAME, $link_identifier)) { > > // run the query > > $queryResultHandle = mysql_query($query, $link_identifier) or > die( > mysql_error() ); > > $ctrRows = mysql_num_rows($queryResultHandle); // row counter > > // if data exists then $rows will be 1 or greater > > if( $ctrRows == 0 ) { > > echo"No data > found"; > > }else{ > > // build the select list > > while($row = mysql_fetch_object($queryResultHandle)) > { // > grab a row > > echo " value=\"$row->country\">$row->country"; > > } > > echo ""; > > > > } > > }else{ // select > > echo mysql_error(); > > } > > }else{ //pconnect > > echo mysql_error(); > > } > > ?> > > > > > > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] question on
Hello, I am very new to php and mysql so please be patient with me. I don't even know if I am using the right listing, but I hope someone can help me! I need to create a and the possible options are from my mysql database ( so far so good, I was able to find code to do that). Now I need to use the user selected option to drive the options of me next . I need to know how to capture what user selected and how to pass that around? I have used "onchange" attribute of the to capture the selected line but now how can I pass that to other php scripts? ( I need to get the name of the country so that I can show a list of possible state/province. I setting the value of the "newcountry" input to the selected "country" but when I do echo $newcountry in quicksearch.php, its blank!!) Please help!! Thanks so much Here is what I have so far: Quicksearch.php file has the following code Steps 1-4 Countrty_buil.php has the following "; // // initialize or capture the country variable $country = !isset($_REQUEST['country'])? "Select a country": $_REQUEST['country']; $countrySQL = !isset($_REQUEST['country'])? "*": $_REQUEST['country']; echo "$country"; $query = "SELECT country FROM ". TABLECOUNTRY . " ORDER BY country ASC"; // pconnect, select and query if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME, DBPASSWORD)) { if ( mysql_select_db(DBNAME, $link_identifier)) { // run the query $queryResultHandle = mysql_query($query, $link_identifier) or die( mysql_error() ); $ctrRows = mysql_num_rows($queryResultHandle); // row counter // if data exists then $rows will be 1 or greater if( $ctrRows == 0 ) { echo"No data found"; }else{ // build the select list while($row = mysql_fetch_object($queryResultHandle)) { // grab a row echo "country\">$row->country"; } echo ""; } }else{ // select echo mysql_error(); } }else{ //pconnect echo mysql_error(); } ?>