Answer the question
In order to leave comments, you need to log in
Why is WHERE selection not working in SQL query?
I’m going crazy, I don’t understand why the WHERE selection in the SQL query does not work, help me find the error, it displays all records from the table at my request
$cat = intval($_GET["cat"]);
$sql = "SELECT * FROM tour WHERE `category` = $cat ";
$query = $pdo->query($sql);
$tours = $query->fetchAll(PDO::FETCH_ASSOC);
Answer the question
In order to leave comments, you need to log in
first hint is to use prepared expressions
second hint is to display your query, copy paste into sql console / phpmyadmin and execute.
retrieves all records from a tableI can assume that this field is not a unique value and it's not surprising that you get ALL records where category = some number.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question