php - Insert in one table and delete from another simultaneously

58
<?php
include("conn.php");
?>
<?php
$name=$_POST['name']; 
$fathers_name=$_POST['fathers_name'];
$gotra=$_POST['gotra'];
$image=$_POST['image'];
$village=$_POST['village'];
$company_name=$_POST['company_name'];
$address1=$_POST['address1'];
$address2=$_POST['address2'];
$city=$_POST['city'];
$pincode=$_POST['pincode'];
$mobile1=$_POST['mobile1'];
$mobile2=$_POST['mobile2'];
$village_number=$_POST['village_number'];
if($_POST['add2'])
{
$i=mysql_query("insert into members_data values(NULL,'".$name."','".$fathers_name."','".$gotra."','".$image."','".$village."','".$company_name."','".$address1."','".$address2."','".$city."','".$pincode."','".$mobile1."','".$mobile2."','".$village_number."')");

$res=mysql_query("SELECT image FROM temp_members_data WHERE 'image' = '$image'");
$row=mysql_fetch_array($res);
mysql_query("DELETE FROM temp_members_data WHERE 'image' = '$image'");


}
?>


<script type="text/javascript">window.location="admin_approve.php"</script>

I need help in inserting in one table and deleting from another table by clicking just add button. Its like adding in main table and deleting from the temp table. Please Help

719

Answer

Solution:

"You must have 50 reputation to comment" >.<

Are you wanting to move this data from one table to another table? From on database to another database? You need to clarify a little bit more on what you are trying to do. Do you have some kind of primary key that you use instead of using an image? (or rather image patch). From my understanding you want to move it from one table to another. If this is the case: Do you NEED to delete that data intemp_members_data or would that just be something that would be nice to have? If it's the latter, then try this:

INSERT INTO new_members_data SELECT * FROM old_members_data WHERE image = '$image'"

People are also looking for solutions to the problem: php - How to get full html content of specific url?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.