grâce à vous (et en particulier Christouphe et Tangan) j'ai identifié l'erreur de ma premiére requête (ligne 49 a 99) : Sur le site Sql compte le nombre d'"ident" correpondants aux critéres alors que je veux le nombre d'"idbees"...mais je ne sais pas où est l'erreur d'encodage car la requête donne le bon résultat après test sql sur phpmyadmin) :
<?php
include('global/haut.php');
include('global/entete.php');
include('global/menus.php');
if(isset($_SESSION['ident']))
{
?>
<!-- Le corps -->
<div id="corps">
<fieldset>
<?php echo 'Bonjour ' . $_SESSION['ident']; ?> bienvenue sur votre espace abonné <br />
<?php
if (isset($_POST['mot_de_passe']) AND $_POST['mot_de_passe'] == "k" OR $_POST['mot_de_passe'] == "a") // Si le mot de passe est bon
{
// On affiche les codes
?>
<?php
try
{
$bdd = new PDO('mysql:host=localhost;dbname=sport', 'root', '');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$reponse = $bdd->prepare('SELECT * FROM demande WHERE ident = ?');
$reponse->execute(array($_SESSION['ident']));
$donnees = $reponse->fetch();
?>
<?php
$reponse = $bdd->prepare('SELECT COUNT(*) AS nb_diplome FROM demande where
diplome = :diplome and
diplome1 = :diplome1 and
dpt = :dpt and
date_dp >= :date_dp and
date_fp <= :date_fp and
heure_lud >= :heure_lud and
heure_luf <= :heure_luf and
heure_mad >= :heure_mad and
heure_maf <= :heure_maf and
heure_med >= :heure_med and
heure_mef <= :heure_mef and
heure_jed >= :heure_jed and
heure_jef <= :heure_jef and
heure_ved >= :heure_ved and
heure_vef <= :heure_vef and
heure_sad >= :heure_sad and
heure_saf <= :heure_saf and
heure_did >= :heure_did and
heure_dif <= :heure_dif'
);
$reponse->execute(array(':diplome' => $donnees['diplome'],
':diplome1' => $donnees['diplome1'],
':dpt' => $donnees['dpt'],
':date_dp' => $donnees['date_dp'],
':date_fp' => $donnees['date_fp'],
':heure_lud' => $donnees['heure_lud'],
':heure_luf' => $donnees['heure_luf'],
':heure_mad' => $donnees['heure_mad'],
':heure_maf' => $donnees['heure_maf'],
':heure_med' => $donnees['heure_med'],
':heure_mef' => $donnees['heure_mef'],
':heure_jed' => $donnees['heure_jed'],
':heure_jef' => $donnees['heure_jef'],
':heure_ved' => $donnees['heure_ved'],
':heure_vef' => $donnees['heure_vef'],
':heure_sad' => $donnees['heure_sad'],
':heure_saf' => $donnees['heure_saf'],
':heure_did' => $donnees['heure_did'],
':heure_dif' => $donnees['heure_dif']
)
);
$donnees = $reponse->fetch();
echo $donnees['nb_diplome'];
$reponse->closeCursor();
?>
candidats correspondent à vos attentes.
<br />
Voici la liste et les coordonnées des candidats selectionnés :
<?php
$reponse = $bdd->prepare("select b.* from bees b join
(select cand.idbees from demande cand, demande client where client.ident !='' and client.ident = :ident and cand.idbees !=''
and client.diplome = cand.diplome and client.diplome1 = cand.diplome1 and client.dpt = cand.dpt
and cand.date_dp <= client.date_dp and cand.date_fp >= client.date_fp
and cand.heure_lud <= client.heure_lud and cand.heure_luf <= client.heure_luf
and cand.heure_mad <= client.heure_mad and cand.heure_maf >= client.heure_maf
and cand.heure_med <= client.heure_med and cand.heure_maf >= client.heure_maf
and cand.heure_jed <= client.heure_jed and cand.heure_jef >= client.heure_jef
and cand.heure_ved <= client.heure_ved and cand.heure_vef >= client.heure_vef
and cand.heure_sad <= client.heure_sad and cand.heure_saf >= client.heure_saf
and cand.heure_did <= client.heure_did and cand.heure_dif >= client.heure_dif)
t on t.idbees = b.idbees");
$reponse->execute(array(':ident' =>$_SESSION['ident']));
while ($donnees = $reponse->fetch())
{
?>
<p>
<?php echo $donnees['civ']; ?> <?php echo $donnees['nom']; ?> <?php echo $donnees['prenom']; ?><br />
Coordonnées :<br /><?php echo $donnees['adresse']; ?> <?php echo $donnees['cplt_adresse']; ?> <?php echo $donnees['code_postal']; ?> <?php echo $donnees['ville']; ?><br />
telephone 1: <?php echo $donnees['fixe']; ?> <br />telephone 2 : <?php echo $donnees['gsm']; ?> <br /> email :<?php echo $donnees['email']; ?>
</p>
<?php
}
$reponse->closeCursor();
?>
</fieldset>
<?php
}
else // Sinon, on affiche un message d'erreur
{
echo '<p>Mot de passe incorrect</p>';
}
?>
</div>
<br />
<?php
}
else
echo '<p>Vous n\'êtes pas connecté(e).</p>';
?>
<?php include("global/pdp.php"); ?>
</html>
la table est composée comme suit :
CREATE TABLE IF NOT EXISTS `demande` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`diplome` varchar(255) NOT NULL,
`diplome1` varchar(255) NOT NULL,
`dpt` varchar(255) NOT NULL,
`date_dp` date NOT NULL,
`date_fp` date NOT NULL,
`lun` int(11) NOT NULL,
`heure_lud` time DEFAULT NULL,
`heure_luf` time DEFAULT NULL,
`mar` int(11) NOT NULL,
`heure_mad` time DEFAULT NULL,
`heure_maf` time DEFAULT NULL,
`mer` int(11) NOT NULL,
`heure_med` time DEFAULT NULL,
`heure_mef` time DEFAULT NULL,
`jeu` int(11) NOT NULL,
`heure_jed` time DEFAULT NULL,
`heure_jef` time DEFAULT NULL,
`ven` int(11) NOT NULL,
`heure_ved` time DEFAULT NULL,
`heure_vef` time DEFAULT NULL,
`sam` int(11) NOT NULL,
`heure_sad` time DEFAULT NULL,
`heure_saf` time DEFAULT NULL,
`dim` int(11) NOT NULL,
`heure_did` time DEFAULT NULL,
`heure_dif` time DEFAULT NULL,
`ident` varchar(255) NOT NULL,
`idbees` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=45 ;
fonctionnement inversé de requête
× Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
× Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.