I recently made a php function , but it isn't working like I want.
This is my code:
<div class="pageContent">
<?php
getComments($conn);
function getComments($conn){
$searchFor = $_POST['keyword'];
$sql = "SELECT adds.* FROM keywords JOIN adds on keywords.productID = adds.id and keywords.keyword LIKE '%".$searchFor."%'";
$result = $conn->query($sql);
while ($row = $result->fetch_assoc()) {
echo "<div class='add'>
<img src='uploads/".$row['imgURL']."'>
<div>
<h1><a>".$row['name']."</a></h1>
<p>".$row['descr']."</p>
</div>
</div>";
}
}
?>
<br />
And the ($conn)
$conn = mysqli_connect("localhost", "root", "", "stp2");
if (!$conn) {
die("Connection failed: ".mysqli_connect_error);
}
When there are normal 2 different results the function is just showing 2 times the same result.
I hope that you guys can help me.