how can i get textarea text rows ??? ... each row to sql table row ...

print("<textarea  name=primary_info_c cols=100 rows=50>".htmlspecialchars($_POST["primary_info_c"])."</textarea>");

how to insert textarea each row in a different row in DB ??

i have a text and replace every spaces in this text with <br> ... now ...

how can i insert each row a get from splitting this text into a database table ... each row from textarea in a different row in database ???

$testNumbers1 = preg_replace('/\s+/',"<br />", $primary_info_c);

example :

text = " aaaaaa sssssss ddddddd ffffffff gggggggg hhhhhhhh jjjjjjjjj "

then i get ...

aaaaaa
sssssss
ddddddd
ffffffff
gggggggg
hhhhhhhh
jjjjjjjjj

and now a need to insert theese
aaaaaa
sssssss
ddddddd
ffffffff
gggggggg
hhhhhhhh
jjjjjjjjj
.. into a mysql db .... every textarea row into a different mysql row ...

any sugestions ?

    you could use explode()

    $string = "aaaaaa\n sssssss\n ddddddd\n ffffffff\n gggggggg\n hhhhhhhh\n jjjjjjjjj";
    $array = explode("\n", $string); //or whatever instance you want it to explode at
    
    $i=0;
    foreach ($array as $value) {
    	mysql_query("INSERT INTO table (column) VALUES ('{$array[$i]}')") or die(mysql_error());
    	$i++;
    }
    

      first is the page where user inserts text : see attachement

      second .... the user gets the text splited in rows by every spaces or tabs or .... see attachements

      and then a need to put numbers at each row ( but i get only number 4 every time ).... and then to insert every row into mysql db

      so .... a have this code but something i dont make right ... 🙁

      
      print("<table align=center width=800px ><tr><td class=headingadd2>");
      
      if ($_GET['action'] == "ccommsr_results") {
      
      $primary_info_c = "<br/>".$_POST["primary_info_c"];
      $testNumbers1 = array( $primary_info_c );
      
      $replacements = array(" +", " ", " ", " ");
      
      
      $allowedchars = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "K", );
      $i=1;
      foreach ($replacements as $v) {
      $testNumbers1 = preg_replace('/\s+/',"<br />".$i." => ", $primary_info_c);
      $i=$i+1;
      
      }
      
      
       print($testNumbers1."<br /> =========testNumbers1");
      
       print($array."<br /> =========array");
      
      
      print("</td></tr></table>");
      
      
      
      } else {
      
      print("<form method=\"post\" action=\"ccommsr.php?action=ccommsr_results\">");
      
      
      print("<textarea id=texta name=primary_info_c cols=100 rows=50>".htmlspecialchars($_POST["primary_info_c"])."</textarea>");
      
      
      print("<br /><input type=submit value=\"".$tracker_lang['go_go_go']."\"></form>");
      
      
      print("</td></tr></table>");
      }
      
      
      

        i am bit confused. why do you like to do that ?? ok lets say you got the solution then doesn't it create a another big problem ?? say if i entered 200 rows in your text area how r u planning to manage r db table??

          there wont be 200 rows

          but i need to do that

            what are you stuck on? what I've provided (with minor edits) will do what you need.

              If you want to populate tables/fields with that,
              why don't you use ',' as separator, and Enter for delimiter?

              If you need to make it Tabulator and enters, first explode your textarea by ENTER (\r)
              Then make another arrays with explode. But use trim() on evry elements you get.

              Or search a preg_match_all (expert) to make this with one step.

                aaaaaaaa=bbbbbbbbb

                how to find out is "=" 14th char or 16th char ???

                  ALMOST DONE ....... BUT NOT YET

                  WILL POST THE CODE WHEN DONE !!!

                  THANKS TO coldwerturkey

                  $string = "aaaaaaaa=bbbbbbbbb"; 
                  $array = explode("=", $string); 
                  $count = strlen($array[0])+1; 
                  
                  echo $count; 

                    special thank you to coldwerturkey

                    here i use:

                    count rows
                    select NEEDED fragment from row an use it for need
                    generate other rows by those inserted

                    i solved this without inserting data to db but it is very easy now to insert it into db if needed

                    
                    print("<table align=center width=800px ><tr><td class=headingadd2>");
                    
                    if ($_GET['action'] == "ccommsr_results") {
                    
                    $primary_info_c = "\n".$_POST["primary_info_c"];
                    
                    $rows = explode("\r", $primary_info_c);
                    
                    
                    $rowcount = (substr_count($primary_info_c, "\n"))."\r\r";
                    
                    $content=explode("\n",$primary_info_c);
                    $i=1;
                    foreach ($content as $value) {
                    
                    $rowrow = ("{$content[$i]}");
                    
                    $dotnumberingex = explode(".", $rowrow); 
                    $dotnumbering= strlen($dotnumberingex[0])+1;
                    
                    $firstspaceex = explode(" ", $rowrow);
                    $firstspace= strlen($firstspaceex[0])+1;
                    $row=substr($rowrow,$dotnumbering,$firstspace)."\n";
                    
                    $row12 = explode("=", $row);
                    $count1 = strlen($row12[0])+1;
                    $count2 = strlen($row);
                    $t1 = "blabla".substr($row, 0, $count1)."blablabla".$row12[1]."";
                    $t2 = ";".$row."";
                    $t3 = "ljalja"."\r\r";
                    
                    //    print($rowtrackresult);
                    
                    if ($i == ($rowcount)) {
                    
                    
                    	break;
                    	}
                    $rowtrackresult = $t1.$t2.$t3;
                    $final.=$rowtrackresult;
                    $i++;
                    }
                    
                    print("<form method=\"post\" action=\"ccommsr.php?action=ccommsr_results2\">");
                    print("<textarea id=texta name=primary_info_c2 cols=100 rows=50>".$result.$final."</textarea>");
                    print("<br /><input type=submit value=\"".$tracker_lang['go_go_go']."\" disabled></form>");
                    print("</td></tr></table>");
                    
                    
                    } else {
                    
                    print("<form method=\"post\" action=\"ccommsr.php?action=ccommsr_results\">");
                    print("<textarea id=texta name=primary_info_c cols=100 rows=50>".htmlspecialchars($_POST["primary_info_c"])."</textarea>");
                    print("<br /><input type=submit value=\"".$tracker_lang['go_go_go']."\"></form>");
                    print("</td></tr></table>");
                    }
                    
                      Write a Reply...