# Drop down SQL Not Displaying

**URL:** <https://forum.kirupa.com/t/drop-down-sql-not-displaying/302792>\
**Category:** programming\
**Created:** [January 7, 2010, 4:47pm UTC](https://forum.kirupa.com/t/drop-down-sql-not-displaying/302792 "2010-01-07T16:47:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wispas](https://avatars.discourse-cdn.com/v4/letter/w/9de0a6/32.png) [@wispas](https://forum.kirupa.com/u/wispas)\
**Post date:** [January 7, 2010, 4:47pm UTC](https://forum.kirupa.com/t/drop-down-sql-not-displaying/302792/1 "2010-01-07T16:47:40Z")

</div>

I currently have a drop down with hotel names loaded.  
When you select a hotel name the description is suppose to show in the div container but does not… im not sure what is wrong with it. Any ideas?

> 

[COLOR=#000000][COLOR=#0000bb]\<?php  
[/COLOR][COLOR=#ff8000]// Connect database  
[/COLOR][COLOR=#007700]include([/COLOR][COLOR=#dd0000]“includes/connectdb.php”[/COLOR][COLOR=#007700]);

[/COLOR][COLOR=#0000bb]$sql[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#dd0000]“SELECT hotel\_id, hotel\_name, hotel\_location, hotel\_desc FROM hotel ORDER BY hotel\_name ASC”[/COLOR][COLOR=#007700];  
[/COLOR][COLOR=#0000bb]$result[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000bb]mysql\_query[/COLOR]COLOR=#007700;

[/COLOR][COLOR=#0000bb]$options[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#dd0000]“”[/COLOR][COLOR=#007700];

[/COLOR][COLOR=#0000bb]$id\_array [/COLOR][COLOR=#007700]= array();  
[/COLOR][COLOR=#0000bb]$hotel\_name [/COLOR][COLOR=#007700]= array();  
[/COLOR][COLOR=#0000bb]$hotel\_location [/COLOR][COLOR=#007700]= array();  
[/COLOR][COLOR=#0000bb]$hotel\_desc [/COLOR][COLOR=#007700]= array();

while ([/COLOR][COLOR=#0000bb]$row[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000bb]mysql\_fetch\_array[/COLOR]COLOR=#007700) {

```
[/COLOR][COLOR=#0000bb]$id_array[/COLOR][COLOR=#007700][]=[/COLOR][COLOR=#0000bb]$row[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]"hotel_id"[/COLOR][COLOR=#007700]];
[/COLOR][COLOR=#0000bb]$hotel_name[/COLOR][COLOR=#007700][]=[/COLOR][COLOR=#0000bb]$row[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]"hotel_name"[/COLOR][COLOR=#007700]];
[/COLOR][COLOR=#0000bb]$hotel_location[/COLOR][COLOR=#007700][]=[/COLOR][COLOR=#0000bb]$row[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]"hotel_location"[/COLOR][COLOR=#007700]];
[/COLOR][COLOR=#0000bb]$hotel_desc[/COLOR][COLOR=#007700][]=[/COLOR][COLOR=#0000bb]$row[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]"hotel_desc"[/COLOR][COLOR=#007700]];
[/COLOR][COLOR=#0000bb]$options[/COLOR][COLOR=#007700].=[/COLOR][COLOR=#dd0000]"&lt;option VALUE='"[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]$row[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]"hotel_id"[/COLOR][COLOR=#007700]].[/COLOR][COLOR=#dd0000]"'&gt;"[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]$row[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]"hotel_location"[/COLOR][COLOR=#007700]].[/COLOR][COLOR=#dd0000]"&lt;/option&gt;"[/COLOR][COLOR=#007700];

```

}

[/COLOR][COLOR=#0000bb]?\>[/COLOR][/COLOR]

\<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd](http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)”\>  
\<html xmlns=“[XHTML namespace](http://www.w3.org/1999/xhtml)”\>  
\<head\>  
\<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” /\>  
\<title\>Untitled Document\</title\>  
\</head\>

\<body\>

\<!–Example drop down menu 1–\>

\<form name=“form1”\>  
\<select name=“select1” size=“1” style=“background-color:#FFFFD7” onChange=“displaydesc(document.form1.select1, thetext1, ‘textcontainer1’)”\>  
[COLOR=#000000][COLOR=#0000bb]\<?php [/COLOR][COLOR=#007700]echo [/COLOR][COLOR=#0000bb]$options[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000bb]?\>[/COLOR][/COLOR]  
\</select\>

\<span id=“textcontainer1” align=“left” style=“font:italic 13px Arial”\>  
\</span\>

\</form\>

\<script type=“text/javascript”\>

echo “var thetext1 = new Array('”.implode(‘','’,$hotel\_desc).“');”;

// Now, see 2) below for final customization step

function displaydesc(which, descriptionarray, container)  
{  
if (document.getElementById)  
document.getElementById(container).innerHTML=descriptionarray[which.selectedIndex]  
}

\</script\>

\</body\>  
\</html\>
