I have a form with a dropdow list and a check box list ...both of them dynamically generated from a database.
how can I get the selected values (from the dropdown and check boxes)to use in php script as variables?
here is the code for the form:
<form action="insert.php" method="POST">
Title: <input type="text" name="title" size="80"><br><br>
Location: <input type="text" name="loco"><br><br>
Company: <select name="comp">
<option value="">Select Company</option>
<?php
$con = mysql_connect('localhost','root','*******') or die (mysql_error());
mysql_select_db('database' , $con );
// dropdown list ------ (can be from 1 to 50 )
$sql = "SELECT `company`.`comp_name` , `company`.`id_comp`
FROM `company`
ORDER BY `company`.`comp_name` ASC";
$result = mysql_query ($sql , $con);
while($row = mysql_fetch_array ($result)){
echo '<option value="'.$row['id_comp'].'"
name="'.$row['comp_name'].'">'.$row['comp_name'].'</option>';
}
?>
</select>
<br><br>
// check box list ----(can be from 1 to 50 boxes )
<?php
$con = mysql_connect('localhost','root','*******') or die (mysql_error());
mysql_select_db('database' , $con );
$sql = "SELECT `category`.`category`, `category`.`id_cat`
FROM `category`
ORDER BY `category`.`category` ASC";
$result = mysql_query ($sql , $con);
while($row = mysql_fetch_array ($result)){
echo '<input type="checkbox" name="'.$row['id_cat'].'">'.$row['category'].'<br>';
}
?>
<br><br>
<input type="submit" style="background-color: #FFD700;">
</form>
I need to use from the dropdown list:
value="'.$row['id_comp'].'"
AND
name="'.$row['comp_name'].'"
and from the check boxes whatever
name="'.$row['id_cat'].'"
....is checked (can be 1 choice or many)
Thanks ...and I am pretty new to this so please have mercy :))