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
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>";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.