Post Database values one table to another table - Mostlikers

29 June, 2013

Post Database values one table to another table

Database value one table values move another table using mysql query . table value get through the id create temp table and move the id value in temp table just insert coding using call the two table value fetch and post
to the another table.


Create the database table 


CREATE TABLE data
(
id INT PRIMARY KEY AUTO_INCREMENT,
message TEXT
);


same table structure create temp table

Data.php


create data page  insert the  value in data table and fetch the table values echo the id give the link

<?php
if(isset($_POST['submit'])!="")
{
    $msg=$_POST['message']; 
    $insert=mysql_query("insert into data(message)values('$msg')");
} 
$page=mysql_query("select * from data");
while($ems=mysql_fetch_array($page))

{
    $function=$ems['message'];
}
?>

id value echo the hyperlink similar <a href="temp.php?id=<?php echo $ems['id']; ?>"><?php echo $function ?></a> 

Temp.php

value get the data page antomaticly values copy and move to temp table

<?php
if(isset($_GET['id']))
{
    $id4=$_GET['id'];
$ins=mysql_query("INSERT INTO `temp` SELECT * FROM `data` where  id='$id4'" )or die(mysql_error());
if($ins)
{
echo "success";
}
else
{
echo mysql_error();
}
}
?>

2 comments:

  1. Can you tell us more about this? I'd like to find out some additional information.

    Also visit my blog - dragonvale eggs

    ReplyDelete