I have a problem with my solution, the result of my while statement doesn't show up.
I have example of this:
function my_function(){
$str = '<div class="my_div">';
$con = mysqli_connect('host','user','password','database');
$sql = "SELECT cola, colb FROM table";
$sql_result = mysqli_query($con, $sql) or die(mysqli_error($con));
while($row = mysqli_fetch_assoc($sql_result)){
$vara = $row['cola'];
$varb = $row['colb'];
...
$str .= 'My text:'.$vara.$varb.'';
}
$str .= '</div>';
return $str;
mysqli_close($con);
}
As result I got only:
<div class="my_div"></div>
Why? How can I display the data from database (MySQL)?
Thanks for help!