need a bit of help for some php code, I can pay a couple of dollars but I am sure it would be really easy for a good php dev.
Discord-TiGeR#9650
Discord-TiGeR#9650
Are the lines properly split using enter, or just moved over to the next line because of a word wrap?I need each line from a textarea to be inserted into the db
Each line a seperate piece of data
^problem, no one has been able to solve it so far, I have had multiple devs dm me.
sorry whatAre the lines properly split using enter, or just moved over to the next line because of a word wrap?
When finished with typing a line, is enter pressed to move it to the next line, or are you relying on it automatically moving the text over to the next line when it reaches the side of the box?sorry what
Oh I am pasting mc accounts in the textarea so its automatically like that basically.When finished with typing a line, is enter pressed to move it to the next line, or are you relying on it automatically moving the text over to the next line when it reaches the side of the box?
So what value would I exactly be inserting?Then use preg_split to split it into an array, and then insert the lines into the database
Example:
Code:$str = $_POST['textarea']; print_r(preg_split('/\r\n|[\r\n]/', $str));
...the textarea nameSo what value would I exactly be inserting?
...the textarea name
Thought you were meaning posting the textarea data, didn't realize you didn't know how to read the code.$sql = "INSERT INTO test (test)
VALUES ('$str)";
So that?
How would I go about looping each line, sorry. Very very new to phpThought you were meaning posting the textarea data, didn't realize you didn't know how to read the code.
You'd need to loop over each line and insert it into the database.
There's better ways to do it, but it'd probably get too complicated.
Why are you trying to make a website without learning basic PHP?How would I go about looping each line, sorry. Very very new to php
I haven't seen getting input from a textarea and inserting each line separately in any basic php tutorialsWhy are you trying to make a website without learning basic PHP?
This is the array you need to loop overI haven't seen getting input from a textarea and inserting each line separately in any basic php tutorials![]()
$arr = preg_split('/\r\n|[\r\n]/', $str)
This is the array you need to loop over
[DOUBLEPOST=1536656200][/DOUBLEPOST]Also read these:Code:$arr = preg_split('/\r\n|[\r\n]/', $str)
- https://stackoverflow.com/questions/8834186/php-split-the-content-of-text-area-and-insert-into-mysql
- https://stackoverflow.com/questions/28907537/get-the-lines-from-textarea-and-insert-to-mysql
- https://wordpress.stackexchange.com...d-echo-each-line-separately-wrapped-with-html
$input = $_POST['accs'];
$arr = explode("\n", $input);
foreach ($arr as $arr1) {
$sql = "INSERT INTO accs (account)
VALUES ($arr1)";
