Jump to content

anargi

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

anargi's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi! I have a question about (dynamic)create table with php script.I don't know if (dynamic) is correct word. I want to create a mysql table but the name of table if it is possible the user to give via html form. my example: This is simple html form where the user he can to insert two fields(id,name) <html> <head> </head> <body> <meta http-equiv="Content-Language"content="en-us-gr"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <form method="POST" action="categ.php"> <table border="1"> <tr><td> <div align="right"> ID: <input type="text" name="id" size="19"> </div> <div align="right"> Name: <input type="text" name="name" size="19"> </div> <div align="right"> <input type="Submit" name="Create" value="create"> </div> </tr></tr> </table> </body> </head> These data send in my database via below code: <?php mysql_connect("localhost","root","MYPASSWORD") or die(mysql_error()); if(mysql_select_db("blog")); { mysql_query("SET NAMES 'utf8'"); } $sql="INSERT INTO menu(id,name) VALUES ('$_POST[id]','$_POST[name]')"; mysql_query($sql); { echo "ok!"; } ///////////////////////////////////////////////////////////////////////////////////// //[b]And here i want to create a table but the name of table if it is possible to be the name where the user gave via above html form.[/b] $qry=mysql_query("CREATE TABLE /*The name of the table via above html form*/ (mycode...mpla...mpla)"); if(!$qry) { die("Table not created\n".mysql_error()); } else { echo "Table Created\n"; } ?> <meta http-equiv="refresh" content="3;url=admin_home.php"> Is there some way to success this result? Thanks!
×
×
  • 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.