mysql - html textbox posted to php create table columns -



mysql - html textbox posted to php create table columns -

i new php , trying learn. illustration not going live!

i have html textbox , posted php. trying break string using explode function , want add together seperate strings select database , table database "columns". help or advice great thanks

$getmessage = $_post["dbmessages"]; $questions = $_post["dbmessagesname"]; $answers = $_post["dbmessages"]; $combined = array_combine($questions, $answers); $dbconnectiont = mysqli_connect($host, $user, $password, $dbname); // create loop assign input boxes foreach($combined $question => $answer) { // create tables , columns message text box $sqlcreatetable = "create table " . $question . "( add together reply column names )"; $answersplit = explode(" ", implode($getmessage)); // if connection , sql query true echo debugging if ($dbconnectiont->query($sqlcreatetable) == true) { echo "created table"; print "{$question} = {$answer} "; echo "</br>"; } }

above code, reply in same text box seperated white space, trying add together answers columns in created tables form.

thanks in advance

per comments-

if column names in string, separated spaces, there no need utilize explode. replace spaces varchar(60),

$columns = "`".str_replace(" ", "` varchar(60), `", $answers)."` varchar(60)"; // wrap column names ` prevent issues reserved words

then utilize in query

$sqlcreatetable = "create table " . $question . "( ". $columns. " )";

php mysql sql

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -