Jump to content

Drop Down linked to Datbase Table


brax23

Recommended Posts

After searching the html posts I'm not quite sure where to post this question.  So I'll first ask "where should I post this question"?  I'm using php and html.  I'd like to produce a page used for entering time worked on a project.  This is a timesheet page.  I'd like to make a drop down menu that's list is populated from a mysql database table containing project numbers.  A text box on the same page would allow me to enter a time value in hours.  Once the project number is selected and the time value is entered into the text box I'd like to select a "submit" button which would take me to another page.  The script on the other page would allow me to use the values from the previous page to update my database so I would need to pass both the drop down value selected (project number) and the value entered in the text box (time value) to the next page.  Can anyone offer any suggestions or perhaps provide guidance on where to search for guidance?

Link to comment
https://forums.phpfreaks.com/topic/118774-drop-down-linked-to-datbase-table/
Share on other sites

This is how to create a drop down box using results from your database

$results = mysql_query( "SELECT pID, pName FROM whereEver ORDER BY id" );

echo "<SELECT ID=project>";
     while( $row = mysql_fetch_array( $results ) ){
           echo "<OPTION VALUE='" . $row['pID'] . "'>" . $row['pName']; 
     }
echo "</SELECT>";

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.