Jump to content

Archived

This topic is now archived and is closed to further replies.

redarrow

[solved]query help please cheers

Recommended Posts

advance thank you.

i want to select all in a table then insert it into another but how cheers.

example

[code]
<?php
$query="select * from shop_information where id='$id' ";
$result=mysql_query($query);

while($record=mysql_fetch_assoc($result)){
foreach($record AS $data) {

$query2="update copy_information set $data where id='$id' ";
$result2=mysql_query($query2);
}
}
?>
[/code]



Share this post


Link to post
Share on other sites
solved

i worked it out this way

select the database and then a while loop then insert to new table and then delete the old info from the 1st table.


[code]
<?php

$query="select * from payment where id='$id'";
$result=mysql_query($query);
while($record=mysql_fetch_assoc($result)){

$id=$record['id'];               
$name=$record['name'];               
$months_payed_for=$record['months_payed_for'];               
$added_date=$record['added_date'];               
$exspire_date=$record['exspire_date'];               
$added_time=$record['added_time'];                 
$user_ip=$record['user_ip'];                 
$price=$record['price'];

$insert="insert into payment_info(id,name,months_payed_for,added_date,exspire_date,added_time,user_ip,price)VALUES(
'$id','$name','$months_payed_for','$added_date','$exspire_date','$added_time','$user_ip','$price')";

$insert_result=mysql_query($insert);

$delete="delete from payment where id='$id' ";
$delete_query=mysql_query($delete);

}
?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.