I am actually having problem with mysql and php script.
i have made code for php to search db for movies and print it back to my html page but i want php to search for movies and its respective link and print back the searched movie name and print it to html doc and when i click that movie name the respective link should be opened. Is it possible to do so
here is my db structure: this is my db structure
search code:
<form method='post' action='second.php'>
<input name='name' placeholder="search..." width="50%">
</form>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "movies";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$getname = $_POST['name'];
$sql = "SELECT movies FROM movies WHERE movies LIKE '%$getname%'";
$result = mysqli_query($conn, $sql);
if ($result->num_rows > 0) {
echo "<table><tr><th></th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr><td>" ;
echo "<a href =\"http://$row[movies]\">".$row['movies']. "</a>";
echo "</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
mysqli_close($conn);
?>