0

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);
?>
Alex
  • 1
  • 4
  • hey hello you cant do like that this is my personal problem and i have not duplicated any question if you know please answer me if not get out – Alex Mar 11 '17 at 15:48
  • and the answer has no matching results i want so plz remove the duplicate tag its very important – Alex Mar 11 '17 at 15:50

0 Answers0