Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // credentials
- $db_user="imageuser";
- $db_pass="password";
- $db_host="localhost";
- $db_name="images";
- // first I define connection string
- $mysqli= mysqli_connect($db_host, $db_user, $db_pass, $db_name);
- $sql_query = "SELECT * FROM urls";
- $result = mysqli_query($mysqli, $sql_query);
- if (mysqli_num_rows($result) > 0) {
- // output data of each row
- while($row = mysqli_fetch_assoc($result)) {
- // first print the title and a line break
- echo $row["title"] . '<br>';
- // show the image url wrapped in an IMG tag
- echo '<img src=' . $row["url"] . '>';
- echo '<hr>';
- }
- } else {
- echo "0 results";
- }
- mysqli_close($mysqli);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement