Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting textarea elements into MySQL from PHP

I need to get all the elements from a textarea in a HTML form and insert them into the MySQL database using PHP. I managed to get them into an array and also find the number of elements in the array as well. However when I try to execute it in a while loop it continues displaying the word "execution" (inside the loop) over a 1000 times in the page.

I cannot figure out what would be the issue, because the while loop is the only applicable one for this instance

$sent = $_REQUEST['EmpEmergencyNumbers'];
$data_array = explode("\n", $sent);
print_r($data_array);
$array_length = count($data_array);
echo $array_length;
while(count($data_array)){
echo "execution    ";  // This would be replaced by the SQL insert statement
}
like image 229
Yoosuf Avatar asked Jun 29 '26 03:06

Yoosuf


1 Answers

you should use 
foreach($data_array as $array)
{
   //sql
}
like image 137
Brandon S Avatar answered Jun 30 '26 17:06

Brandon S