Jump to content

[solved]query help please cheers


redarrow

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]



Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.