I am trying to display multiple images to the screen using PHP.
I have a database that has paths to each image in pictures folder which contains movie pictures.
below is my HTML file.
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/navbarstyles.css" type="text/css">
<link rel="stylesheet" href="css/home_page.css" type="text/css">
</head>
<body>
<div class="nav">
<nav class="header">
<ul>
<li><a href="home-page.html">Home</a></li>
<li><a href="MyMovies.html">My Movies</a></li>
<li><a href="AboutUsPage.html">About</a></li>
<li><a href="Contact.html">Contact</a></li>
<li><a href="CartPage.html">Cart</a></li>
<li><a href="UserSettings.html">Settings</a></li>
</ul>
</nav>
</div>
<div class="browse">
<div class="column">
<input type="text" placeholder="Search" name="search"><br>
<input type="checkbox" name="movies" value="releases" style="margin-bottom:15px">New Releases<br>
<input type="checkbox" name="movies" value="popular" style="margin-bottom:15px">Popular<br>
<input type="checkbox" name="movies" value="action" style="margin-bottom:15px">Action<br>
<input type="checkbox" name="movies" value="adventure" style="margin-bottom:15px">Adventure<br>
<input type="checkbox" name="movies" value="animated" style="margin-bottom:15px">Animated<br>
<input type="checkbox" name="movies" value="comedy" style="margin-bottom:15px">Comedy<br>
<input type="checkbox" name="movies" value="cooking" style="margin-bottom:15px">Cooking<br>
<input type="checkbox" name="movies" value="drama" style="margin-bottom:15px">Drama<br>
<input type="checkbox" name="movies" value="family" style="margin-bottom:15px">Family<br>
<input type="checkbox" name="movies" value="horror" style="margin-bottom:15px">Horror<br>
<input type="checkbox" name="movies" value="romance" style="margin-bottom:15px">Romance<br>
</div>
</div>
<div class="movies">
<div class="column">
<img src="getImage.php" style="width:100%" />
</div>
</div>
</body>
</html>
Now as you can see I have getImage.php file.
<?php
$servername = "localhost";
$username = "usern";
$password = "password";
$conn = new mysqli($servername, $username, $password);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "select * from portfolio";
$result = mysql_query($sql) or die("Invalid query: " .mysql_error());
while ($rows = mysql_fetch_array($result))
?>
<img src="pictures/<?php echo $row['movie_paths']; ?>">
<?php
What I am trying to do here is to connect to my database then loop over them and display each picture to the screen. My pictures are under pictures folder and movie_paths column contains the paths to images in the pictures folder.
I get Uncaught Error: Call to undefined function mysql_query().
Why does my looping not display any image?