The problem is there is an enquiry page which contains multiple checkboxes, date, client name and so on and there are 2 tables main_enquiry and sub_enquiry. what i need to do is when i insert an enquiry into main_enquiry table the same enquiry id along with the selected checkboxes(the checkboxes are dynamically called from another table) need to be inserted into sub_enquiry table in different rows but with same enquiry id. i'm using php to do this
i tried with many answers in stackoverflow but can't find a solution.
`if (isset($_POST['submit']))
{
$cli=$_POST['serv'];
$dt=$_POST['date'];
$rq=$_POST['requiremnts'];
$fi=$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'], "attachments/".$fi);
$path="attachments/".$fi;
$sqlenq=mysql_query("insert into tbl_enquiry (client_id,enquiry_date,enquiry_requirement) values ('$cli','$dt','$rq')");
if ($insid=mysql_insert_id())
{
$sqlenqsel=mysql_fetch_array(mysql_query("select * from tbl_enquiry where enquiry_id='$insid'"));
$enq=$_POST['enqid'];
$check=$_POST['subenq'];
foreach ($check as $value)
{
$sqlsubenq=mysql_query("insert into tbl_sub_enquiry set enquiry _id='$enq',enq_categories='$serv'");
}
}
}`
`<div class="col-12 col-sm-5 col-lg-5">
<?php
while ($showcat=mysql_fetch_array($cat))
{
?>
<label class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" checked="" class="custom-control-input"
name="subenq"><span class="custom-control-label" value="<?php echo
$showcat['services_category_id'];?>"><?php echo
$showcat['services_category_name'];?></span>
</label>
<?php } ?>
</div>`
if there is a more easier way then that is preferred.
Aucun commentaire:
Enregistrer un commentaire