0

for example i already have an existing table name (Bronze) what i want is to create an another table called Bronze1,Bronze2,Bronze3,Bronze4, and so on . . in the table name

this is the sample of my code please help

for($i = 1; $i<99 ; $i++) {

   $this_table = 'Bronze'.$i;

   $create =mysql_query("Create Table $this_table")
}
5
  • 1
    So what is your problem? Commented Jul 9, 2015 at 10:20
  • i don't know how to put the right code in the loop there to create the table bronze1,bronze2,bronze3, and so on. so hard to explain >.< can give me an example that might work sir? Commented Jul 9, 2015 at 10:28
  • 1
    how can you create a table without column list? Commented Jul 9, 2015 at 10:28
  • You want to make 2 tabels in 1 loop?, Just store the tables in a variable and ouput them after the loop. Commented Jul 9, 2015 at 10:28
  • i want to create it 1by1 for example bronze1 already created ,then the nxt time i refresh the php bronze2 will be created then bronze3,then bronze4 . .. Commented Jul 9, 2015 at 10:36

1 Answer 1

1

Try this SQL-statement:

CREATE TABLE new_tbl LIKE orig_tbl;

in your case:

for($i = 1; $i<99 ; $i++) {
   $this_table = 'Bronze'.$i;
   $create =mysql_query("Create Table $this_table LIKE Bronze")
}

that will create a table based on another one.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.