Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <a href="www.mysite.com/showimage.php?id=1">Show image 1</a>
- <?php
- $imageid = $_GET['id'];
- $servername = ...;
- $username = ...;
- $password = ...;
- $dbname = ...;
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("Connection to MySQL failed: " . $conn->connect_error);
- }
- htmlspecialchars($imageid);
- stripslashes($imageid);
- mysqli_real_escape_string($conn, $imageid);
- $sql = "SELECT * FROM images WHERE id = '$imageid'";
- $result = $conn->query($sql);
- if (is_object($result) && $result->num_rows > 0) {
- while($row = $result->fetch_assoc())
- {
- // Replace "image, image_name ecc." with the columns of the table
- echo $row["image"];
- echo "Name: " . $row["image_name"];
- echo "Info: " . $row["image_useful_info"];
- echo "Price: " . $row["image_price"];
- }
- $conn->close();
- die();
- }
- else
- echo "The image you requested was not found.";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement