Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Database connection
- $dbconn = new mysqli('mysql17.000webhost.com', 'a2083177_mydb', 'password1', 'a2083177_mydb');
- if(mysqli_connect_errno())
- {
- die("MySQL connection failed: ". mysqli_connect_error());
- }
- $u_id = $_SESSION['user_id'];
- // query to display existing files
- $sql = "SELECT * FROM `files` where `u_id` ='$u_id'";
- $result = $dbconn->query($sql);
- // check for success
- if($result)
- {
- // Files exist?
- if($result->num_rows == 0)
- {
- echo '<br><p>There are no files.</p>';
- }
- else
- {
- // table headings
- echo '<br>
- <table width="70%">
- <tr>
- <td><b>Name</b></td>
- <td><b>Type</b></td>
- <td><b>Size</b></td>
- <td><b>Received</b></td>
- <td><b> </b></td>
- <td><b> </b></td>
- </tr>';
- // table data
- while($row = $result->fetch_assoc())
- {
- echo "
- <tr>
- <td>{$row['name']}</td>
- <td>{$row['type']}</td>
- <td>{$row['size']}</td>
- <td>{$row['created']}</td>
- <td><a href='deletefile.php?u_id={$row['u_id']}'>Delete</a></td>
- <td><a href='downloadfile.php?u_id={$row['u_id']}'>Download</a></td>
- </tr>";
- }
- echo '</table>';
- }
- $result->free();
- }
- else
- {
- echo 'Error! query failed:';
- echo "<pre>{$dbconn->error}</pre>";
- }
- // Close the connection
- $dbconn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement