Gem Posted November 21, 2009 Share Posted November 21, 2009 Hi all, Basically, what I'm trying to do it populate the drop down list with the names that are in the query (that works) but it's not happening, and I dont know why... <php? $conn = mysql_connect("CONNECTION") or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('bssql',$conn) or trigger_error("SQL", E_USER_ERROR); if(isset($select)&&$select!=""){ $select=$_GET['select']; } ?> <html> <body> <form action="<?php echo $PHP_SELF;?>" method="get"> <select name="select"> <option value="Select"></option> <?php $list=mysql_query(" select distinct pname from pname, comp_result where comp_result.pname_id=pname.name_id ;")?> <option value="<? echo $list; ?>" </option> </select> <input type="submit" /> </form> </body> </html> <html> <body> This is what I'm getting back: PHP Warning: mysql_query() [function.mysql-query]: Can't connect to MySQL server on 'localhost' (10061) in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\test.php on line 21 PHP Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\test.php on line 21 Hope you can help, this was supposed to be the easy bit, I still got to get it to display the info I want once its been submitted ?! Grrr Thanks Gem Link to comment https://forums.phpfreaks.com/topic/182432-drop-down-list-help-please/ Share on other sites More sharing options...
Gem Posted November 21, 2009 Author Share Posted November 21, 2009 OK- Clearly im stupid ... I put <php? at the beginning !! MUPPET. Still, the error is gone, but its still not got anything in the drop down list ... xx Link to comment https://forums.phpfreaks.com/topic/182432-drop-down-list-help-please/#findComment-962752 Share on other sites More sharing options...
Gem Posted November 21, 2009 Author Share Posted November 21, 2009 bump Link to comment https://forums.phpfreaks.com/topic/182432-drop-down-list-help-please/#findComment-962768 Share on other sites More sharing options...
cbrooks Posted November 21, 2009 Share Posted November 21, 2009 look at this code Dynamic DropDown PHP/AJAX. It has several complete examples using and not using MySQL. It is show how to do something else, but the code that you need is there. Link to comment https://forums.phpfreaks.com/topic/182432-drop-down-list-help-please/#findComment-962786 Share on other sites More sharing options...
Gem Posted November 21, 2009 Author Share Posted November 21, 2009 link doesn't work mate Link to comment https://forums.phpfreaks.com/topic/182432-drop-down-list-help-please/#findComment-962788 Share on other sites More sharing options...
cbrooks Posted November 21, 2009 Share Posted November 21, 2009 Sorry about that, try this http://www.phpfreaks.com/forums/index.php/topic,277549.0.html Link to comment https://forums.phpfreaks.com/topic/182432-drop-down-list-help-please/#findComment-962790 Share on other sites More sharing options...
Gem Posted November 21, 2009 Author Share Posted November 21, 2009 I found it, thank you I dont really understand what I am looking at though .. the whole ajax thing is confusing me I'll try and work it out Link to comment https://forums.phpfreaks.com/topic/182432-drop-down-list-help-please/#findComment-962797 Share on other sites More sharing options...
cbrooks Posted November 21, 2009 Share Posted November 21, 2009 start looking at the code that starts as //for use with my FIRST list box this builds the $List1 which is what you want your page to dispaly then look at the part that starts as <!-- OK a basic form--> on the line that starts <select> delete out onchange="ajaxFunction('LBox2', this.value);" that is the ajax stuff that you don't need. so your line would look like <td><select name="list1" id="LBox1"> Link to comment https://forums.phpfreaks.com/topic/182432-drop-down-list-help-please/#findComment-962800 Share on other sites More sharing options...
garethhall Posted November 21, 2009 Share Posted November 21, 2009 Please confirm that your sql query is working. So make the query a variable and echo it out, the test in phpmyadmin or what ever it is you use. Link to comment https://forums.phpfreaks.com/topic/182432-drop-down-list-help-please/#findComment-962855 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.