0

Hi,
I need some help, I am trying to insert multiple check boxes values(this values comes from 1st database) and I am giving the check boxes in the output(result fetch from 1st database).
I want to insert all selected values into to the 2nd database from 1st database using PHP.

for E.g mysql backend:-1st
database name:- sss1
Table name: abc
fields name: A, B,C and D

2nd
database name:- sss2
Table name: abc
fields name: A, B,C and D

so i want to insert the selected data to 2nd databse using checkboxes(values fetch from 1st database) in php.

thanks in advance.

2
Contributors
2
Replies
5
Views
5 Years
Discussion Span
Last Post by harsha.netpem
0

You need to store the post selection of checkboxes in an array. So you would call your checkboxes all the same name and create an array from those selected.

name="nameofcheckboxes[value_id]"
0

Hi,
I am trying to insert multiple check boxes values(this values comes from 1st database) and I am giving the check boxes in the output(result fetch from 1st database). I want to insert all selected values into to the 2nd database from 1st database using PHP.

for E.g mysql backend:-1st database name:- sss1 Table name: abc fields name: A, B,C and D

2nd database name:- sss2 Table name: abc fields name: A, B,C and D

so i want to insert the selected data to 2nd databse using checkboxes(values fetch from 1st database) in php.
please check the code is given below:-

I dont understand how i make the insert query in check.php

Checkbox.php

<?php
$db=mysql_connect("localhost","root","");
mysql_select_db("sss1",$db);
$qry="select * from  abc  ,pqr  
where abc.company_id ='$c_id' and pqr.c_id=abc.company_id";
$result=mysql_query($qry);
?>
<form action=”check.php”   method=”post”>
<table>
<tr><th>A</th>
<th>B</th>
<th>C</th>
<th>D</th>
<th>E</th>

</tr>

  <?php
while($row=mysql_fetch_array($result))
{
echo "<tr><td><input type=checkbox name=name[] value='".$row1['s_id']."'>".$row['A']."</td><td>".$row['B']."</td><td>".$row['C']."</td></tr>";
 }
?>
<input type="submit" value="save" id="submit>

Check.php

<?php
$db=mysql_connect("localhost","root","");
mysql_select_db("sss2",$db);
foreach($_POST[‘name'] as $x)
{
$qry="INSERT INTO xyz()values()”;
mysql_query($qry);
}
?>

Database name:sss1
Table name: abc

A B C D
1 2 3 4


Database name: sss2
Table name: xyz

A B C D
1 2 3 4

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.