I'm trying to get data to html table from database. In the database there's a company table which consists of id, name and percentage columns.
The above data in the table is entered by me manually. I need to fill those the same values by retrieving from database.
And company table in the database looks like this.Database table
In my coding it's getting an error in the place of array formation. I tried to get all the names in to one array and print in the html table. I'm kindly requesting to have a look at my coding. Highly appreciated.
$sql = "SELECT name, percentage FROM company";
$result = $conn->query($sql);
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row= $result->fetch_assoc()) {
$arr=str_split($row)
//echo $row;
echo "<table> <tr> <td> $arr[1] </td> </tr> </table> ";
}
} else {
echo "0 results";
}
@jakumi Error is enter image description here. Line 18 is '$arr=str_split($row);'.
;in this line$arr=str_split($row)