Hi there, I've just started using mysql & php. I want to know how I can use user inputed data for values in a table. Here is my source: <form method="post" action="add.php" /> ID: <input type="text" name="id" /> <input type="submit" /> </form> HTML: add.php <?php $id = $_POST["id"]; // Connects to your Database mysql_connect("localhost", "xxxxxxx", "xxxxxxx") or die(mysql_error()); mysql_select_db("testing") or die(mysql_error()); mysql_query("CREATE TABLE $id ( name VARCHAR(30), age INT, car VARCHAR(30))"); Print "Your table has been created"; ?> PHP: As you can see in my source, I am wanting to use the user inputed data ($id) to use for the table name. How do I go about doing this? - I am just mucking around... Cheers
Also, after further investigation, I notice that values with a decimal point get rounded. eg When I added 22.50 it showed in phpmyadmin as 23... how do I keep it as 22.50 without it rounding?
While creating the table instead of int type you will have to give the decimal type and you can set the rounding like (0,2) 2 means the precision. If you are using the phpmyadmin its easy to implement