Ok please forgive me, as I am really new to the whole PHP programming...
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:
[CODE=php]<select name="comapny_l ist" size="1" id="company_lis t">
<?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>Th ere was an error and we could load the Client list</center>");
$result = mysql_result($q uery);
while ($row = mysql_fetch_arr ay($result)){
$comp_name = $row2['company'];
echo "<option value='$comp_na me'>{$comp_name }</option>";
}
?>
<option value=""></option>
</select> [/CODE]
Any suggestions would be much appreciated! Thanks!
*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
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:
[CODE=php]<select name="comapny_l ist" size="1" id="company_lis t">
<?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>Th ere was an error and we could load the Client list</center>");
$result = mysql_result($q uery);
while ($row = mysql_fetch_arr ay($result)){
$comp_name = $row2['company'];
echo "<option value='$comp_na me'>{$comp_name }</option>";
}
?>
<option value=""></option>
</select> [/CODE]
Any suggestions would be much appreciated! Thanks!
*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
Code:
PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /htdocs/forms/orderform2.php on line 30
Comment