0

hi guys,
i wanted a table to get created with the table name submitted from the form.
how shall i go about this, i have tried it with my basic knowledge its here bellow but it dint work well, please help me anyone.

<?php 
if (isset($_POST['update']))
{
mysql_connect('localhost', 'root', 'jackson');
extract($_POST);
mysql_query("CREATE table `praveen` . '$_POST[id]'(id int, amount varchar(10), DTMY text(30))");
}
?>
<form name="new_member" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="new_member">
	<h4>New Member</h4>
    <label>id :</label><br />
    <input name="id" type="text" id="id" value="<?php print rand(1, 100000); ?>" readonly="readonly" /><br />
    <input type="submit" value="update" name="update" />
</form>
2
Contributors
3
Replies
7
Views
6 Years
Discussion Span
Last Post by smantscheff
0

It is a bad idea to have structurally identical tables created at runtime. What for? Put all the info in one table.
If you still want to do it that way, set correct quotes in your query. Within single quotes PHP will not replacement variables, with double quotes it will. Change your query to

mysql_query('CREATE table praveen' . $_POST['id'] . '(id int, amount varchar(10), DTMY text(30))');

}

0

thanks smantscheff so much bro wat u told was right i had some mistakes wit my quotes i got it working now...................

http://www.lkrvk.com/

Edited by lkrvk: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.