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>

Recommended Answers

All 3 Replies

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))');

}

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/

Please mark this thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.