i am having an issue with an SQL query, using limits. I'd like to have a variable limit parameters. As i've done successfully elesewhere in my site, i wanted to use something like LIMIT number = :number then specify 'number'=>$numberResults.
Somehow, this doesn't work.. (i've tried, if i write out LIMIT 20 in my query it works fine, but that isn't the issue.
Here's my code :
connexion_bdd.php
<?php
try
{
$bdd = new PDO('mysql:host=localhost;dbname=mise_a_quai_tardive', 'root', '');
}
catch (Exception $e)
{
die('Erreur : ' . $e->getMessage());
}
?>
mise_a_quai_tardive.php That is giving me issues
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="style.css" />
<title>Module Suivi des Mises à Quai Tardives</title>
</head>
<body>
<?php include("connexion_bdd.php"); ?>
<?php
$resultatsParPage = 15;
$reponse = $bdd->prepare("SELECT id_dossier, type_sortie, date_incident, no_train, commentaire FROM sortie_prevue
UNION
SELECT id_dossier, type_sortie, date_incident, no_train, commentaire FROM sortie_non_prevue
ORDER BY date_incident DESC LIMIT limit=:limit")
$reponse -> execute(array('limit'=> $resultatsParPage));
while ($donnees = $reponse->fetch())
{
/* i display the results here, they display fine with a 'static' SQL query, but nothing shows up with my query at the moment.. */
}
</body>
</html>
thanks a lot for your help ! I'm sure there is a simple explanation to this ! :)