I am trying to create a table with columns from users form input. a text box creates the database, another textbox creates the tables and using javascript more textboxes can be created, which creates more tables. Now I have a textbox next to the "table" textbox, which can accept entries such as: "id item quote price" The total number of inputs is unknown could be four to six for example, but I am trying to create columns in the tables based on these values. Only one column is created in the database, which is the last value, for example price, but I am trying to get all values into the correct table.
$getMessage = $_POST["dbMessages"];
$questions = $_POST["dbMessagesName"];
$answers = $_POST["dbMessages"];
$combined = array_combine($questions, $answers);
$dbConnectionT = mysqli_connect($host, $user, $password, $dbName);
// create loop to assign input boxes together
foreach($combined as $question => $answer)
{
$answerSplit = explode(" ", implode($getMessage));
foreach ($answerSplit as $split)
{
// create the tables and columns from the message text box
$sqlCreateTable = "CREATE TABLE " . $question . "(
" . $split . " VARCHAR(6)
)" ;
echo $split;
echo "</br>";
}
// if the connection and sql query is true echo for debugging
if ($dbConnectionT->query($sqlCreateTable) == TRUE) {
print "{$question} = {$answer} ";
//echo "made it here";
echo "</br>";
}
}
So i am trying to splitthe text box using explode and trying to update the question table with the related answer split. Please note, for this example I understand my violation on the database primary key and not worried about the database key aspects, for this example!!
Thanks in advance
$splityou generate, you will only ever execute ONEcreatequery.