Jump to content

drop down list help please


Gem

Recommended Posts

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

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">

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.