Jump to content

[SOLVED] populating a select list from database


technotool

Recommended Posts

Hi, I am trying to populate a selection element in a form with a database list.  The tricky part is that I am trying to store the form in a variable called $output. which I am adding to by concatination (.= )  This $output is then getting echo'ed at the end of the file.

 

I am very close. I am getting a selection item but the output is not the information from the database but literally  "$short_desc &nbsp $icd9" within the selection list.  interestingly, the number of  "$short_desc &nbsp $icd9" displayed is exactly the same number of items in the table.  what am I missing. thanks.

 


<?php
include_once ("../mylibrary/debug.php"); debug();   //debug
include_once ("../mylibrary/db_connect.php"); db_connect();   //database connection file
require_once ("../config/config.php");  //configuration file with POST[array] conversions


$output= <<<END
<html>
<head>
html stuff here.....

END; //here is the selection element

$output .= '<select name="icd9_dx">';
$query="SELECT id,icd9,short_desc,long_desc FROM diagnosis_spine"; 
$result=mysql_query($query); 
while($row=mysql_fetch_array($result,MYSQL_ASSOC)) 
{ 
    $temp_id=$row['id'];
    $icd9=$row['icd9'];
    $short_desc = $row['short_desc'];
    $long_desc=$row['long_desc']; 
$output .= '<option value="$temp_id">$short_desc &nbsp $icd9</option>'; 
}
$output .= '</select>'; 
$output .= '</form>';


$output .=<<<END
<form name="test" onsubmit="return updateFormValues();" action="../_p/underline_p.php"  method="POST">

  <input type="hidden" name="places" id="places" value="" size="80">
  <br>

  <input type="hidden" name="orders" id="orders" value="" size="80">
  <br>

  <button type="submit">Submit</button>
  <input type='reset'  value='Reset'>
</form>
</body>
</html>
END;
echo $output;

?>

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.