mysql到html表,换行符 为一行

I have mysql table

With 3 columns: id, name, number.

Some of the name, number fields have more than one enetry, but they are seperated with linebreak. But there are allways the same amount of enterys in name and number.

Example:

name; number
First
; fists

Second
 third
; Second
 third

How can i get them appear in html table as different rows.

ive tried to make this happen with:

if(strpos($string, "
") !== FALSE) {

But this only get me so far as i know when there is more than 1 entry. And as even with one entry i still have linebreak its not realy helping

You can use explode for separating the lines from your SQL result. http://php.net/manual/de/function.explode.php

$nameFromDatabase = "a 
 b 
 c";
$numberFromDatabase = "1 
 2 
 3";

$names = explode("
", $nameFromDatabase);
$numbers = explode("
", $numberFromDatabase);

for ($i = 0; $i < count($names) && $i < count($numbers); $i++) {
    echo "<tr><td>" + $names[i] + "</td><td>" + $numbers[i] + "</td></tr>";
}

Here is another method to bring it to a table:

$str = 'name; number
First
; fists

Second
 third
; Second
 third
';

$exploded = explode('
',$str);
array_walk($exploded,function(&$value){
    $value = '<td>'.$value.'</td>';
});

echo '<table><tr>'.implode('</tr><tr>',$exploded).'</tr></table>';