Hi, am trying to display the filename after upload but can't display, instead error message "There are no files in the database" is displayed. Please advise. Thanks.
<?php
// Connect to the database
$dbLink = new mysqli('localhost','user','','pq');
if(mysqli_connect_errno()) {
die("MySQL connection failed: ". mysqli_connect_error());
}
// Get the ID
// Query for a list of all existing files
$progressid=$row['Progressid'];
//echo $progressid;
$id= $row['id'];
echo $id;
$sql = 'SELECT `id`, `name`, `mime`, `size`, `created`,`Progressid` FROM `tfile` where `id`=$row['id']';
$result = $dbLink->query($sql);
// Check if it was successfull
if($result) {
// Make sure there are some files in there
if($result->num_rows == 0) {
echo '<p>There are no files in the database</p>';
}
else {
// Print the top of a table
echo '<table width="100%">
<tr>
<td><b>Name</b></td>
</tr>';
// Print each file
while($row = $result->fetch_assoc()) {
echo "
<tr>
<td><a href='get_file.php?id={$row['id']}'>{$row['name']}</td>
</tr>";
}
// Close table
echo '</table>';
}
// Free the result
$result->free();
}
else
{
echo 'Error! SQL query failed:';
echo "<pre>{$dbLink->error}</pre>";
}
// Close the mysql connection
$dbLink->close();
?>