Hello all! I use a form where I enter some text consisting of several sentances! How can I save each sentance to MySQL separately? I use this php script, but it saves all text that was entered to the form $query = "INSERT INTO mytable (table1) VALUES ('$textform')" ; Thx for help!
By separately you mean in new line? If that's the case, you can use php built in function called nl2br which converts new line in text field to break tags. Use it like this, $text= nl2br($text); now put this into the database. To echo out the formatted text use following echo nl2br($text);
No no ... I mean each sentence to new row in the mysql table. I heard that I need to use explode function! But how? I have no idea!
Here is a simple example that might work. $mytext = "this a first sentence. This is second. This is third"; $onesentence = explode(".", $mytext); echo $onesentence[0]; echo $onesentence[1]; echo $onesentence[2]; In your case you will store $onesentence[0] and other two in database row.
I know this simple examples, but I need help how to make it with query Here it is my query which saves all that was in the input form: $query = "INSERT INTO mytable (table1) VALUES ('$textform')" ; So could you help me?
$mytext = "this a first sentence. This is second. This is third"; $onesentence = explode(".", $mytext); foreach($onesentence as $sentence) { mysql_query("INSERT INTO table tablecol value '$sentence'"); } PHP:
$form1 = explode(". ", $mytext); $form2 = explode(". ", $mytext2); $query = "INSERT INTO enru (table1, table2) VALUES ('$mytext', '$mytext2')" ; $result = mysql_query( $query ) or die( mysql_error() ) ; PHP: So I did so, but it does not work!