If you use PDO, you can make a simple query to the db:
$query = $pdo->prepare("SELECT * FROM table_name WHERE category = ?");
$query->bindValue(1, $category);
$query->execute();
return $query->fetch();
If you have never used PDO before, this might look confusing, but the actual query to the db (SELECT * FROM...) will work for whichever method you're using. But I recommend using PDO for all your stuff.
You can also use MySQLi to accomplish this. Here is an example.
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM yourtablename WHERE category = 'ford'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"] . " - Name Ads: " . $row["NameAds"] . " - Category: " . $row["category"] . " - Price: " . $row["price"] . "<br />";
}
} else {
echo "0 results";
}
$conn->close();
?>
This will echo out all results matching what you're asking for. You would just change the end echo statements to match the names of what you have in your database.
This answer here provides an excellent way to use the MySQLi example above as a prepared statement (similar to the first PDO example I gave). https://stackoverflow.com/a/750686/2374753