manjumadhav93 Posted September 18, 2014 Share Posted September 18, 2014 As a complete newbie to php and webdesigning i have a following problem.I would like to retrieve the data from database and display it in a drop down menu.Then i should allow the user to select the values from drop down list along with other details,in other words i have to embed the drop down output as the form input for the user and store the form data in another table.I am running a xampp server and i am using php 5.4 version.Please help.My code is as follows.In this case project_name is displayed as the drop down output.but how do i use the same drop down output as a input in the form. <html><head></head><body><?phperror_reporting(E_ALL ^ E_DEPRECATED);include 'connect.php' ;$tbl_name="projects";$sql="SELECT project_name FROM $tbl_name ";$result=mysql_query($sql);if($result === FALSE) { die(mysql_error());}?><form name="resources" action="hourssubmit.php" method="post" ><?phpecho "<select name='project_name'>";while ($row = mysql_fetch_array($result)) { echo "<option value='" . $row['project_name'] ."'>" . $row['project_name'] ."</option>";}echo "</select>";?></form></body></html> Link to comment https://forums.phpfreaks.com/topic/291149-retrieve-the-data-from-database-and-display-it-in-a-drop-down-menu-and-again-use-the-same-as-form-input-in-php/ Share on other sites More sharing options...
Barand Posted September 18, 2014 Share Posted September 18, 2014 Add a submit button to you form. When user clicks it, it will post the selected project_name to hourssubmit.php where you can access it with $_POST['project_name'] Link to comment https://forums.phpfreaks.com/topic/291149-retrieve-the-data-from-database-and-display-it-in-a-drop-down-menu-and-again-use-the-same-as-form-input-in-php/#findComment-1491497 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.