Hello I would like how I can transform the following code to use BindValues and to do the same job.
$sql = "SELECT * FROM documents WHERE 1";
if (!empty($topic)) { $sql .= " AND topic = '$topic' "; }
if (!empty($date )) { $sql .= " AND date LIKE '%$date%' "; }
WHERE clause to be applied only on the filled input So my question is how to transform this code in to the the following query
$sql = new page($pages "SELECT * FROM table WHERE topic LIKE :topic OR date LIKE :date ", $option);
$sql ->BindValue(':topic ', $_POST['topic '], PDO::PARAM_STR);
$sql ->BindValue(':date ', $_POST['date '], PDO::PARAM_STR);
Aucun commentaire:
Enregistrer un commentaire