-1

I have this CREATE statement that if I run it in PHPmyAdmin it works fine, which is to say, it picks our the records and inserts them back in the main table via temporary tables. I need to know how to reproduce this functionality in a PHP statement, or at least how to port it over to PHP and get it to perform the same function when the page loads? Here's my statement:

CREATE TEMPORARY TABLE tmp SELECT * from TableA WHERE ColumnA = 'some_word';
    ALTER TABLE tmp drop ID; # drop autoincrement field
    UPDATE tmp SET ColumnA = CONCAT('copy_',ColumnA);
    INSERT INTO TableA SELECT 0,tmp.* FROM tmp;
    DROP TABLE tmp;

Ultimately, I'll want to have a table pass a value dynamically to 'some_word', so I can choose from a checkbox next to a field name value, and click the Submit and have the page effectively clone that record, appending the text in ColumnA.

Clear as mud?

Peter O.
  • 32,158
  • 14
  • 82
  • 96

1 Answers1

0

The default php5-mysql library can't do more than 1 query (thats why you dont need ';' in it).

Try the other available libraries that are able to do COMMITS and execute more than 1 query:

PDO is easy to use: http://php.net/manual/de/pdo.commit.php

Also see similiar question: make a temporary table and select from it

I don't think people are going to do the markup and form validation for you if that's the question..

Community
  • 1
  • 1
Daniel W.
  • 31,164
  • 13
  • 93
  • 151