I'm trying to display data from database in bootstrap datatables. The thing is that I have book with more than one author, so I have one array for first names and second for last names. And now I have trouble displaying it in < td >
.
Is it good way to get fnames and lnames in two arrays and try to display it that way or is there any other option?
My table and arrays:
Here is my code in which I display data:
$sql2 = "SELECT fname, lname FROM `books_has_authors` JOIN authors on books_has_authors.authors_id_author = authors.id_author
WHERE books_has_authors.books_book_id = '".$row["book_id"]."'";
$result2 = mysqli_query($conn, $sql2);
$authors_array = array();
$authors_array2 = array();
//Getting data names of all authors
while($row2 = mysqli_fetch_assoc($result2)){
$authors_array[] = $row2['fname'];
$authors_array2[] = $row2['lname'];
}
echo '<pre>';
print_r($authors_array);
print_r($authors_array2);
echo '</pre>';
echo '
<tr>
<td>'.$row["name"].'</td>
<td>'.$row["year"].'</td>
<td>
//Here I want display those names each in new line if possible
</td>
</tr>
';