Insert into new table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Wackie
Forum Newbie
Posts: 14
Joined: Sat Mar 15, 2008 6:21 am

Insert into new table

Post by Wackie »

Hi all.

I hope you can help me with this.

I'm using macromedia flash to send data to php to mysql.

It works perfectly, but I want to put the received data in a new table each time.

How do I do that?

Here is my code...

Code: Select all

<?php
$DBhost = "localhost";
$DBuser = "root";
$DBpass = "************";
$DBName = "DB";
$table = "Table";
$Var01 =  $_POST['Var01'];
$Var02 =  $_POST['Var02'];
$Var03 =  $_POST['Var03'];
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
 
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
 
$sqlquery = "INSERT INTO $table VALUES('$id','$Var01','$Var02','$Var03')";
 
$results = mysql_query($sqlquery);
 
mysql_close();
?>
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Insert into new table

Post by aceconcepts »

Would the new table already be created or would you create "on the fly"?
User avatar
Wackie
Forum Newbie
Posts: 14
Joined: Sat Mar 15, 2008 6:21 am

Re: Insert into new table

Post by Wackie »

The table would not already be created.

Well, the plan is to be able to write a name for the table in flash.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Insert into new table

Post by aceconcepts »

Use a search engine to lookup "CREATE TABLE".

Once you know how to create a table all you'd need to do is pass the table name as a variable like you have already declared.
User avatar
Wackie
Forum Newbie
Posts: 14
Joined: Sat Mar 15, 2008 6:21 am

Re: Insert into new table

Post by Wackie »

Ok, thanks.
Post Reply