Jump to content

php var inside file.sql


hyster

Recommended Posts

im trying to create a table for a site admin. bsicaly all he has to do is fill out a form and the values of the form are turned into the table name.

 

im using a .sql file as a template but to create the table i need the php genarated table name to be inserted into the .sql file.

 

<?php
include("config.php");
$con details

$tbl_name = "static_name_for_now";
if (mysql_query("seat_plan.sql")) { 
  echo "success"; 
} else{
echo "fail"; 
}
?>

 

sql file snippet

INSERT INTO `<?php $tbl_name ?>` VALUES('A', 1, 0, 'Y');

also tried

 

INSERT INTO `<?php echo $tbl_name ?>` VALUES('A', 1, 0, 'Y');

thanks

 

Link to comment
Share on other sites

i can load the sql file now and it runs ok apart from there is no table name which i want to use as $var

table.sql file snippet

INSERT INTO `<?php  echo $tbl_name?>` VALUES('A', 1, 0, 'Y');
INSERT INTO `<?php  echo $tbl_name?>` VALUES('A', 2, 0, 'Y');
INSERT INTO `<?php  echo $tbl_name?>` VALUES('A', 3, 0,'Y');
INSERT INTO `<?php  echo $tbl_name?>` VALUES('A', 4, 0,'Y');

 

atm im getting

INSERT INTO `` VALUES('A', 1, 0,'Y');
INSERT INTO `` VALUES('A', 2, 0,'Y');
INSERT INTO `` VALUES('A', 3, 0,'Y');
INSERT INTO `` VALUES('A', 4, 0,'Y');

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.