technotool Posted May 26, 2008 Share Posted May 26, 2008 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   $icd9" within the selection list. interestingly, the number of "$short_desc   $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   $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; ?> Link to comment https://forums.phpfreaks.com/topic/107319-solved-populating-a-select-list-from-database/ Share on other sites More sharing options...
BlueSkyIS Posted May 26, 2008 Share Posted May 26, 2008 you can save yourself some headaches down the road if you get used to single-quoting html parameters and double-quoting strings in php: $output .= "<option value='$temp_id'>$short_desc   $icd9</option>"; Link to comment https://forums.phpfreaks.com/topic/107319-solved-populating-a-select-list-from-database/#findComment-550228 Share on other sites More sharing options...
technotool Posted May 26, 2008 Author Share Posted May 26, 2008 7 minutes. Can I get some service around here. I mean really. thanks. Link to comment https://forums.phpfreaks.com/topic/107319-solved-populating-a-select-list-from-database/#findComment-550232 Share on other sites More sharing options...
mushroom Posted May 26, 2008 Share Posted May 26, 2008 Try removing 7 minutes. Can I get some service around here. I mean really. thanks. Are you paying for service ??? try removing your END: statment Link to comment https://forums.phpfreaks.com/topic/107319-solved-populating-a-select-list-from-database/#findComment-550238 Share on other sites More sharing options...
BlueSkyIS Posted May 26, 2008 Share Posted May 26, 2008 (twas sarcasm followed by a sincere thanks.) Link to comment https://forums.phpfreaks.com/topic/107319-solved-populating-a-select-list-from-database/#findComment-550241 Share on other sites More sharing options...
technotool Posted May 26, 2008 Author Share Posted May 26, 2008 thanks again. I was being sarcastic of course. rolling my eyes => Link to comment https://forums.phpfreaks.com/topic/107319-solved-populating-a-select-list-from-database/#findComment-550260 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.