3 Replies - 2188 Views - Last Post: 14 May 2012 - 08:06 PM Rate Topic: -----

#1 smaboud  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 119
  • Joined: 22-April 12

copy all rows from one table to another

Posted 14 May 2012 - 06:28 AM

Hi

I want to copy all rows from some specific fields of one table into other table but the code doesn't do the copy

The HTML code

<footer>
<form name="finalsubmit" id="finalsubmit_id" action="submitorder.php">
<input name="finalsubmitBTN" type="button" value="Submit your order"> 
</form>
</footer>
</body>

</html>






The php page for the transferring rows



<?php


$con = mysql_connect('localhost', 'root', '');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("userinfo", $con);
         session_start();
         $SE_userID = $_SESSION['UserId'];
         $table_select= "t".$_SESSION['UserId']; 


$copysql=mysql_query("INSERT INTO order_detail ('user_id','order_id','product_id','link','photo','unit_price','qty','total_price','express','comission','customer_st') SELECT ('user_id','order_id','product_id','link','photo','unit_price','qty','total_price','express','comission','customer_st') FROM t2790") ;



?>





Help please

Is This A Good Question/Topic? 0
  • +

Replies To: copy all rows from one table to another

#2 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 282
  • View blog
  • Posts: 1,489
  • Joined: 07-April 08

Re: copy all rows from one table to another

Posted 14 May 2012 - 07:56 AM

Get rid of the ()'s in the select statement aswell as the single quotes from everything and you should be fine

change
$copysql=mysql_query("INSERT INTO order_detail ('user_id','order_id','product_id','link','photo','unit_price','qty','total_price','express','comission','customer_st') SELECT ('user_id','order_id','product_id','link','photo','unit_price','qty','total_price','express','comission','customer_st') FROM t2790") ;



to

$copysql=mysql_query("INSERT INTO order_detail (user_id,order_id,product_id,link,photo,unit_price,qty,total_price,express,comission,customer_st) SELECT user_id,order_id,product_id,link,photo,unit_price,qty,total_price,express,comission,customer_st FROM t2790") ;


This post has been edited by rgfirefly24: 14 May 2012 - 07:59 AM

Was This Post Helpful? 1
  • +
  • -

#3 smaboud  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 119
  • Joined: 22-April 12

Re: copy all rows from one table to another

Posted 14 May 2012 - 08:01 PM

it seems that the HTML button dos not call the page,
when i run the transferring php page it transfers the rows but when I press the button from another page to call the transferring php page the button seems not doing anything


here is the button, I even moved out of the footer and put it in the same frame as the table is, but it still not calling the transferring.php
<footer>
<form name="finalsubmit" id="finalsubmit_id" action="submitorder.php">
<input name="finalsubmitBTN" type="button" value="Submit your order"> 
</form>
</footer>
</body>





View Postrgfirefly24, on 14 May 2012 - 07:56 AM, said:

Get rid of the ()'s in the select statement aswell as the single quotes from everything and you should be fine

change

$copysql=mysql_query("INSERT INTO order_detail (user_id,order_id,product_id,link,photo,unit_price,qty,total_price,express,comission,customer_st) SELECT user_id,order_id,product_id,link,photo,unit_price,qty,total_price,express,comission,customer_st FROM t2790") ;


Was This Post Helpful? 0
  • +
  • -

#4 smaboud  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 119
  • Joined: 22-April 12

Re: copy all rows from one table to another

Posted 14 May 2012 - 08:06 PM

hi, it works now, change the input type to submit and it works now, thank you all for the sql
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1