I am trying to figure out how to take multiple word input in a single text box in a form with each word separated by comma(,) and then paring the word based on comma and inserti
I know a bunch of mysql_* function answers are going to come in, so ill add the prepared query route.
This isn't flawless, but you'll get the idea
// Get the array of words
$words = explode( ',', $formname );
// Create an array of :word1, :word2, :word3, etc for use in binding
foreach( range( 1, count( $words ) ) as $wordnumber ) {
$bind[] = ':word'.$wordnumber;
}
// Create the sql query
$sql = sprintf( "insert into table ( word ) values ( %s )", implode( '),(', $bind ) );
// Prepare the query
$stmnt = $pdo->prepare( $sql );
// Bind each word
foreach( $words as $k => $word ) {
$stmnt->bindValue( ":word" . ++$k, $word );
}
// Execute
$stmnt->execute();