I am working on a php project and I have a problem printing data from the database. The connection is working, the empty table is printed but when it comes to print the data, nothing is showed.My currently code:
<?php
$con = mysqli_connect('localhost','root','root', 'db');
$user = $_SESSION['sess_user'];
$query=("SELECT * FROM urls WHERE owner = '".$user."'");
$qry_result = mysqli_query($con,$query);
$display_string = "<table>";
$display_string .= "<tr>";
$display_string .= "<th> Id</th>";
$display_string .= "<th> Url</th>";
$display_string .= "<th> Owner </th>";
$display_string .= "<th> SharingUrls </th>";
$display_string .= "</tr>";
while($row = mysqli_fetch_array($qry_result)) {//doesn't enter in this loop
echo 'sdf'; //?? nothing
$display_string .= "<tr>";
$display_string .= "<td>$row[id]</td>";
$display_string .= "<td>$row[url]</td>";
$display_string .= "<td>$row[owner]</td>";
$display_string .= "<td>$row[sharingUsers]</td>";
$display_string .= "</tr>";
}
$display_string .= "</table>";
echo $display_string;
?>
What can be the problem?
session_start();at your page??