Advertisement

05.08.2008 at 01:31PM PDT, ID: 23387580
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

Using option list to populate field in MYSQL database

Asked by dpassero in PHP Scripting Language, PHP and Databases, MySQL Server

Tags: ,

I am working on a php form and I want to use a drop-down list that pulls a value from one table in a mysql database to populate a field in a related table.  The  two tables are vendors and requisitions.  The user will be able to choose a vendor name from the vendor table and dump the results into the related field in the requisitions table.  My form is attached.  How do I get the selected value to populate a field in the requisitions table?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
<form name='requisitions' action="<?php echo ($_SERVER['PHP_SELF']); ?>" method='post'>
		    <table border="0" cellspacing="3" cellpadding="6" width="768">
              <tr><td width="175" align="right">Requisition Number:</td><td><input type="text" size="6" name="req_num" value="<?php if(isset($_POST['req_num'])); ?>"></td></tr>
			  <tr><td width="175" align="right">Requisition Date (yyyy-mm-dd):</td><td><input type="text" size="10" name="req_date" value="<?php if(isset($_POST['req_date'])); ?>"></td></tr>
              <tr><td width="175" align="right">Sent To (initials):</td><td><input type="text" size="2" name="sent_to" value="<?php if(isset($_POST['sent_to'])); ?>"></td></tr>
			  <tr><td width="175" align="right">Date Sent (yyyy-mm-dd):</td><td><input type="text" size="10" name="date_sent" value="<?php if(isset($_POST['date_sent'])); ?>"></td></tr>
              <tr><td width="175" align="right">Vendor:</td><td><?php if (isset($_POST['vendor_id']));
											   connect();
											   $query = "SELECT vendor_name, vendor_id FROM vendors ORDER BY vendor_name";
											   $result = @mysql_query ($query) or die('Error: ' . mysql_error()); // Run the query.
											   // printing the list box select command
                                               echo "<select name='vendor' value=''>";
											   echo "<option value='choose'>Choose from list ...</option>";
											   echo "<option value='divider'>------------------</option>";
                                               while($nt=mysql_fetch_array($result)){  //Array or records stored in $mfg_array
                                                 echo "<option value=$nt[vendor_id]>$nt[vendor_name]</option>";  //Option values are added by looping through the array
                                               } // end of while
											 echo "</select>";
											 mysql_close; ?></td></tr>
              <tr><td width="175" align="right">Account Number:</td><td><input type="text" size="12" name="account_num" value="<?php if(isset($_POST['account_num'])); ?>"></td></tr>
              <tr><td width="175" align="right">Amount:</td><td><input type="text" size="8" name="amount" value="<?php if(isset($_POST['amount'])); ?>"></td></tr>
			  <tr><td colspan="2"><hr /></td></tr>
			  <tr><td width="150" align="right"><input type="submit" name="submit" value="Submit Entry" /></td><td><input type="reset" name="reset" value="Clear Form" /></td></tr>
            </table>
		  </form>
[+][-]05.08.2008 at 01:53PM PDT, ID: 21528379

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.09.2008 at 02:12AM PDT, ID: 21531245

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.15.2008 at 03:18PM PDT, ID: 21578423

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, PHP and Databases, MySQL Server
Tags: PHP $ MYSQL, IE 7
Sign Up Now!
Solution Provided By: dpassero
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628