I have problem inserting my value to my database I have this code
<?php if(isset($_POST['next'])) {
for($x=1;$x<=$sites;$x++)
{
$sql = "SELECT * FROM category where status = '1' ";
$results = mysql_query($sql) or die(mysql_error());
while($rows = mysql_fetch_array($results, MYSQL_ASSOC))
{
$cat="cat".$x;
$site="site".$x;
//echo $category."<br>";
}
}
$items = array();
$itemss = array();
foreach($_POST['site'] as $value) {
$items[] = $value;
$sql = "SELECT * FROM sitelist where name = '$value' ";
$results = mysql_query($sql) or die(mysql_error());
while($rows = mysql_fetch_array($results, MYSQL_ASSOC))
{
$idc = $rows['name'];
$qx="INSERT INTO site (sitename) VALUES ('".$idc."')";
$result=mysql_query($qx);
}
}
$try = $_POST['checkbox'];
$N = count($try);
$tet = array();
foreach($_POST['checkbox'] as $values) {
$tet[] = $values;
$lol = implode("','",$tet);
//echo $values;
echo $lol;
//$qx="INSERT INTO site (studyid,sitename,category,status) VALUES ('".$studid."','".$total."','".$try[$i]."','1')";
$qx = "UPDATE site
SET studyid='$studid',
category='$lol',
status = '1'
WHERE sitename IN
( SELECT name
FROM sitelist
)";
$result=mysql_query($qx);
//echo($try[$i] . " ");
}
}
?>
The form is a drop down combobox and a checbox which are not constant and depends on the value in the db. What I want is if user picks a value in combo box and also checed their deside category it will be save in my db in a 1 row I want an output something like this if the user have 2 combobox with different values and 4 checkbox each on every combobox Let say and the user pick combobox1 value 1 checkbox1 value1 checkbox 2 value 2 and combobox 2 checkbox3 value 3 checkbox4 value 4
but unfortunately the checkbox output on my code is like checkbox 1-4 is all the same value