Sounds like you're on the right track. in the <select> list, add --> onChange="document.form.submit()" <-- this will submit the form when the user selected the an option from the list, then you could catch the submitted variable and pass it to the second drop down list and third and so on. Realizing htat you'll also get unwanted fields in this submission *if* they already exist on the form, so you'll have to deal with those as well, or just ignore them. hth Jeff Allens <ateam3@mac.com> To: php-db@lists.php.net cc: 08/18/2003 03:47 Subject: Help with filling a second drop down List from a prior list selection PM in the same page Hello, Have tried for a day to figure out how to dynamically fill a second drop-down list from the first using PHP and Javascript. Still new to both would greatly appreciate some direction. Below is an example. Thanks in advance. :) All of this is inside an HTML form so that the user can add a request for computer equipment. 1. Drop-down list one is of vendors that I've acquired from a php call to mysql to select all vendors in a table. 2. Want the second drop-down list to dynamically acquire from mysql the vendor contacts for the vendor chosen in drop-down list 1. The rest of the form I can handle. Will PHP allow me to do this without Javascript? I know that I could just have a page list the drop-down list of the vendors inside a form and have submit button there. Then $_post that value in another page to fill the second list and display the remaining html to get the remaining data, but it would be nice if I could do both lists on one page. I've searched the web all day looking for examples of using php and mysql with Javascript to do this, but haven't found any that I can get a handle on. Any help would be greatly appreciated. :) On Monday, August 18, 2003, at 07:11 AM, php-db-digest-help@lists.php.net wrote: > > > > php-db Digest 18 Aug 2003 11:11:40 -0000 Issue 1987 > > Topics (messages 29926 through 29934): > > Re: AGONIZING Mysql Select DB issue. > 29926 by: Micah Stevens > > test - Please ignore > 29927 by: vish.kohli > > Query runs fine on Console but not in PHP > 29928 by: vish.kohli > > mysql date select statement > 29929 by: Wendell Frohwein > 29930 by: John W. Holmes > 29931 by: Shahmat Dahlan > > Is there a better way to write this? > 29932 by: Chris Payne > > Popup menu problem > 29933 by: Kim Kohen > 29934 by: John W. Holmes > > Administrivia: > > To subscribe to the digest, e-mail: > php-db-digest-subscribe@lists.php.net > > To unsubscribe from the digest, e-mail: > php-db-digest-unsubscribe@lists.php.net > > To post to the list, e-mail: > php-db@lists.php.net > > > ---------------------------------------------------------------------- > > > > > > From: Micah Stevens <micah@raincross-tech.com> > Date: Sun Aug 17, 2003 4:56:24 PM US/Eastern > To: Thomas Deliduka <thomas@xenocast.com>, PHP-DB List > <php-db@lists.php.net> > Subject: Re: AGONIZING Mysql Select DB issue. > > > > Try using the SQL to select which database. > > example, instead of: > > select * from table1 > > use: > > select * from database1.table1 > > if that works, and the php command doesn't that may mean the the mysql > client > lib is broken, although, I've been using it with mysql 4 and it seems > to work > fine. > > -Micah > > > On Sunday 17 August 2003 1:49 pm, Thomas Deliduka wrote: >> I'm not making two connections, I'm making one and only one call to >> mysql_connect. Also, there is no way in that function as per the >> definition page of it (http://us3.php.net/mysql_connect) to have the >> database selected as per your example below. >> >> With my connection though, when I do: >> $dbh = Mysql_connect(blah, blah, blah) >> Mysql_select_db("db1") >> >> I do call: >> Mysql_query("query", $dbh); >> >> For some reason even though I am calling mysql_select_db("db1") it is >> latching onto the first available database it has access to (or not >> as the >> case/permissions may be) and chooses "db2" instead. >> >> I don't know why, connecting to the MySQL 3.23 it selects the right >> database, connecting to the Mysql 4.x server it doesn't allow a >> selecting >> of the table even though I do the select function and it returns true >> as it >> was selected properly. >> >> On 8/16/03 12:23 AM this was written: >>> If you are doing this: >>> >>> $dbh = mysql_connect("db1", blah blah blah); >>> $dbh2 = mysql_connect("db2", blah blah blah); >>> >>> Then >>> >>> $r = mysql_query("select * from mytable"); >>> >>> will use the db2 connection, because it is the most recent. >>> However, if >>> you do this: >>> >>> $r = mysql_query("select * from mytable", $dbh); >>> >>> it will use the first connection, as specified in the handle that is >>> passed back by mysql_connect. mysql_query uses the most recent >>> connection by default; you can override this action by specifying >>> which >>> DB handle to use for a given query. Replace $dbh with $dbh2 to >>> select >>> from tables on the second database. >>> >>> Peter >>> >>> On Fri, 15 Aug 2003, Thomas Deliduka wrote: >>>> Here's the stats: >>>> >>>> Two servers: >>>> >>>> Server 1, Mysql 4.0.12, PHP 4.3.2, apache 1.3.27 >>>> Server 2, Mysql 4.0.14, PHP 4.3.2, apache 1.3.27 >> >> -- >> >> Thomas Deliduka >> IT Manager >> ------------------------- >> Xenocast >> Street Smart Media Solutions >> http://www.xenocast.com/ > > > > > > > > > From: "vish.kohli" <vish.kohli@attbi.com> > Date: Sun Aug 17, 2003 4:50:23 PM US/Eastern > To: php-db@lists.php.net > Subject: test - Please ignore > > > Please ignore, this is a test > > > > > > > > > > From: "vish.kohli" <vish.kohli@attbi.com> > Date: Sun Aug 17, 2003 4:56:39 PM US/Eastern > To: php-db@lists.php.net > Subject: Query runs fine on Console but not in PHP > > > Hi, > > I am trying to execute a stored procedure in PHP via mssql_query () > function. I pass 8 parameters to it. > The query runs fine in SQL Query Analyzer but when I run it thru PHP, > it > behaves strangely. I can get number of rows (mssql_num_rows()) and > number of > fields (mssql_num_fields()) in PHP, but when I try to execute > mssql_fetch_object() or mssql_fetch_array() on the same result > identifier, I > get a "Page could not be displayed" (standard internet error page). > > Please help. > Thanks in advance. > > > > > > > > > > From: Wendell Frohwein <wendell@3rdpixeldesignstudio.com> > Date: Mon Aug 18, 2003 12:07:43 AM US/Eastern > To: php-db@lists.php.net > Subject: mysql date select statement > > > Hello all, I have this page where I search and add up commissions in a > mysql database. I want to select commissions between a certain date > range. > This is what im currently using but it does not seem to work. > > > $from="20030101"; > $to="20031230"; > > $search=mysql_query("SELECT SUM(amount) FROM commissions WHERE date > BETWEEN '$from' AND '$to'"); > > > > Thanks in advance for any help > > > > wendell > > > > > > > > From: "John W. Holmes" <holmes072000@charter.net> > Date: Mon Aug 18, 2003 12:09:30 AM US/Eastern > To: Wendell Frohwein <wendell@3rdpixeldesignstudio.com> > Cc: php-db@lists.php.net > Subject: Re: mysql date select statement > Reply-To: holmes072000@charter.net > > > Wendell Frohwein wrote: > >> Hello all, I have this page where I search and add up commissions in a >> mysql database. I want to select commissions between a certain date >> range. >> This is what im currently using but it does not seem to work. >> $from="20030101"; >> $to="20031230"; >> $search=mysql_query("SELECT SUM(amount) FROM commissions WHERE date >> BETWEEN '$from' AND '$to'"); > > Always use mysql_error() with your queries to see the error. You do > not have a GROUP BY clause in your query, so it's failing. > > -- > ---John Holmes... > > Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ > > PHP|Architect: A magazine for PHP Professionals ? www.phparch.com > > > > > > > > > > > > From: Shahmat Dahlan <shahmatd@sains.com.my> > Date: Mon Aug 18, 2003 12:09:36 AM US/Eastern > To: Wendell Frohwein <wendell@3rdpixeldesignstudio.com> > Cc: php-db@lists.php.net > Subject: Re: mysql date select statement > > > hav u tried using dashes to denote which portion is the year, month, > or day ? > e.g. instead of 20030101, you'd probably want to use 2003-01-01. > > Wendell Frohwein wrote: > >> Hello all, I have this page where I search and add up commissions in a >> mysql database. I want to select commissions between a certain date >> range. >> This is what im currently using but it does not seem to work. >> $from="20030101"; >> $to="20031230"; >> $search=mysql_query("SELECT SUM(amount) FROM commissions WHERE date >> BETWEEN '$from' AND '$to'"); >> Thanks in advance for any help >> wendell >> >> > > > > > > > > > > From: Chris Payne <chris@planetoxygene.com> > Date: Mon Aug 18, 2003 12:16:11 AM US/Eastern > To: php <php-db@lists.php.net> > Subject: Is there a better way to write this? > > > Hi there everyone, > > I'm re-writing the messageboard that my boss uses, and I wanted to > know if there's a cleaner way to do the below code. The first bit > gets the name of the forum by the ID sent from the previous page to > display the forum name, then the second bit gets some of the info for > the message listing. The forum name is NOT stored in the actual > messages table, it's in the forum index table I created. > > The code I use is: > > <? > > include("../../connectionstart.php"); > > $query = "SELECT * FROM forums WHERE ForumID = '$ForumID' ORDER BY > ForumID ASC"; > > $sql_result = mysql_query($query,$connection) > or die("Couldn't execute query."); > > while ($row = mysql_fetch_array($sql_result)) { > > $Forum = $row["Forum"]; > > }; > > $query = "SELECT * FROM forummessages WHERE ForumID = '$ForumID' ORDER > BY ForumID ASC"; > > $sql_result = mysql_query($query,$connection) > or die("Couldn't execute query."); > > while ($row = mysql_fetch_array($sql_result)) { > > $id = $row["id"]; > $MessageID = $row["MessageID"]; > $ForumID = $row["ForumID"]; > $subject = $row["subject"]; > > }; > ?> > > Thanks for taking a look :-) > > Chris > > > > > > > > From: Kim Kohen <kim@webguide.com.au> > Date: Mon Aug 18, 2003 3:04:17 AM US/Eastern > To: PHP <php-db@lists.php.net> > Subject: Popup menu problem > > > G'day all, > > I've struck a problem with an existing piece of code which I want to > move > to a new one. I'm aware of the issues with register global being off > as far > as forms are concerned, but I can't figure out why this snippet doesn't > work. It displays the code rather than the popups. > > <?php > $db_name = "torch"; > $table_name = "stories" > > $connection = @mysql_connect("localhost","user","paswword") or > die("Couldn't > Connect."); > $db = @mysql_select_db($db_name, $connection) or die("Couldn't select > database."); > > $getlist = mysql_query("SELECT distinct Writer FROM stories order by > Writer"); > echo " <select name=\"WriterName\">\n"; > echo " <option>\n"; > while ($row = mysql_fetch_array($getlist)) { > echo ' <option > value="'.$row["Writer"].'">'.$row["Writer"]."</option>\n"; > } > echo " </select>\n"; > ?> > > > As I said, it works fine on our current web server (apache 1.3x with a > similar vintage PHP and MySQL) but I have built the new server with > Apache > 2.0.47, MySQL 4 and PHP 4.3.2 (on MacOSX 10.2.6). I've pretty much > ruled > out MySQL because the query returns the correct result when run from > the > CLI. > > I have another couple of pages which use hard coded popups and they > work > fine. PHP seems fine as I can display phpinfo() without problem. > > Any help, as always, would be greatly appreciated. > > cheers > > kim > > > > > > > > > From: "John W. Holmes" <holmes072000@charter.net> > Date: Mon Aug 18, 2003 7:11:32 AM US/Eastern > To: Kim Kohen <kim@webguide.com.au> > Cc: PHP <php-db@lists.php.net> > Subject: Re: Popup menu problem > Reply-To: holmes072000@charter.net > > > Kim Kohen wrote: > >> G'day all, >> I've struck a problem with an existing piece of code which I want to >> move >> to a new one. I'm aware of the issues with register global being off >> as far >> as forms are concerned, but I can't figure out why this snippet >> doesn't >> work. It displays the code rather than the popups. > > If you're seeing the PHP source code in the window, then PHP is not > configured correctly. Are you calling a file with a .php extension > (dumb question, I know, but you never know). > > There's no difference in calling a PHP file through a popup or through > a regular link. The code you showed didn't look wrong, show us how > you're calling this code. > > -- > ---John Holmes... > > Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ > > PHP|Architect: A magazine for PHP Professionals ? www.phparch.com > > > > > > > > > :) Gale L. Allen Jr Macintosh Support Specialist Phone: 919/412-5039 Homepage: http://homepage.mac.com/ateam3/Menu5.html iChat = ateam3@mac.com "Remember, It's only Rock 'n Roll, but I like it!" (: -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php