What I am attempting to do is on a form page create a drop down list that is populated from information in a database. For example a list of company names, then with this that would populate one more drop down list with the department they belong to if any.
Once both of those are chosen and the user hits submit it would populate text fields below. For example Name, company, phone number, email so on and so forth.
At this point the first drop down list box shows up but is empty. Here is the code I have for that:
Expand|Select|Wrap|Line Numbers
- <select name="comapny_list" size="1" id="company_list">
- <?php
- include "config.php";
- //connect to the mysql server
- $link = mysql_connect($server, $db_user, $db_pass) or die("Could not connect to MySQL");
- //select the database
- mysql_select_db($database) or die ("Could not select database");
- // Filling up the selection box
- $query = mysql_query ("SELECT * FROM " . $table . " WHERE 'Active' = '1'", $link) or die("<center>There was an error and we could load the Client list</center>");
- $result = mysql_result($query);
- while ($row = mysql_fetch_array($result)){
- $comp_name = $row2['company'];
- echo "<option value='$comp_name'>{$comp_name}</option>";
- }
- ?>
- <option value=""></option>
- </select>
*Edit here is the error form the error log sorry about that...
Wrong parameter count for mysql_result() in /htdocs/forms/orderform2.php on line 29
Expand|Select|Wrap|Line Numbers
- PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /htdocs/forms/orderform2.php
- on line 30