Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // session, formatting, etc.
- include('header.php');
- // connect to database, dry code
- include('db.php');
- // the query
- $sql= "SELECT * FROM urls ";
- $result=mysqli_query($conn, $sql);
- if(mysqli_connect_errno() || $result==false)
- {
- // handle error
- } else {
- $count=mysqli_num_rows($result);
- echo $count.' results<br>';
- if($count>0)
- {
- // output data of each row
- while($row = mysqli_fetch_assoc($result))
- {
- // htmlentities to prevent xss
- // first print the title and a line break
- echo htmlentities($row["title"], ENT_QUOTES) . '<br>';
- // show the image url wrapped in an IMG tag
- echo '<img src="' . htmlentities($row["url"], ENT_QUOTES) . '" >';
- echo '<hr>';
- }
- }
- }
- mysqli_close($conn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement