Aller au contenu
  • Pas encore inscrit ?

    Pourquoi ne pas vous inscrire ? C'est simple, rapide et gratuit.
    Pour en savoir plus, lisez Les avantages de l'inscription... et la Charte de Zébulon.
    De plus, les messages que vous postez en tant qu'invité restent invisibles tant qu'un modérateur ne les a pas validés. Inscrivez-vous, ce sera un gain de temps pour tout le monde, vous, les helpeurs et les modérateurs ! :wink:

erreur de programmation pdo/sql


olly

Messages recommandés

utilise une jointure dans ta requête

select ... from demande
inner join bees on demande.idbees = bees.idbees
where ...

 

reste à savoir si les relations entre tes tables sont correctes

1 bees est-il associé à 1 seule ou plusieurs demandes (relation 1:1 ou 1:n) ou plusieurs bees peuvent ils être associés à plusieurs demandes (relation m:n)

Je remarque qu'il n'y a pas de clés étrangères de définies dans tes tables

 

MySQL :: MySQL 5.0 Reference Manual :: 13.1.7.1 Syntaxe de JOIN

Cours de MySQL - Pierre Aulas

Modèle relationnel - Wikipédia

Lien vers le commentaire
Partager sur d’autres sites

1 bees peut être associé à plusieurs demandes et plusieurs bees peuvent correspondre à une demande.

 

Mais ce qui doit ressortir à l'écran c'est le nombre de bees associés à une demande puis ensuite leurs coordonnées.

 

voilà mon code :

<?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 />
<strong>Les candidats potentiels sont : </strong> <br />
<?php
try
{
$bdd = new PDO('mysql:host=localhost;dbname=sport', 'root', '');
}
catch(Exception $e)
{
       die('Erreur : '.$e->getMessage());
}

$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 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>

   Identité : <?php echo $donnees['civ']; ?>  <?php echo $donnees['nom']; ?>  <?php echo $donnees['prenom']; ?><br />
   Coordonnées :<?php echo $donnees['adresse']; ?> <?php echo $donnees['cplt_adresse']; ?> <?php echo $donnees['code_postal']; ?> <?php echo $donnees['ville']; ?><br />
   telephone fixe: <?php echo $donnees['fixe']; ?> de mobile <?php echo $donnees['gsm']; ?>  email : <?php echo $donnees['email']; ?>
  </p>
<?php
}

$reponse->closeCursor(); 

?>

Pour revenir à votre profil <a href="voirprofilcl.php">cliquez ici</a>
</fieldset>

</div>

<br />

   <?php 

}
else
echo '<p>Vous n\'êtes pas connecté(e).</p>';
?>	

<?php include("global/pdp.php"); ?>    

</html>

 

et ca marche (sur des tests simples).

J'accepte toutes les critiques.

 

Merci

Lien vers le commentaire
Partager sur d’autres sites

  • 3 semaines après...

Salut,

 

J'ai retravaillé mon code mais il ne compte pas et ne me done pas les infos souhaitées :

<?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'];

?>
candidats correspondent à vos attentes.
<br />
Voici la liste et les coordonnées des candidats selectionnés :


<?php


try
{
$bdd = new PDO('mysql:host=localhost;dbname=sport', 'root', '');
}
catch(Exception $e)
{
       die('Erreur : '.$e->getMessage());
}


$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>

 

quelqu'un peut me dire ou est l'erreur ?

Lien vers le commentaire
Partager sur d’autres sites

Rejoindre la conversation

Vous pouvez publier maintenant et vous inscrire plus tard. Si vous avez un compte, connectez-vous maintenant pour publier avec votre compte.
Remarque : votre message nécessitera l’approbation d’un modérateur avant de pouvoir être visible.

Invité
Répondre à ce sujet…

×   Collé en tant que texte enrichi.   Coller en tant que texte brut à la place

  Seulement 75 émoticônes maximum sont autorisées.

×   Votre lien a été automatiquement intégré.   Afficher plutôt comme un lien

×   Votre contenu précédent a été rétabli.   Vider l’éditeur

×   Vous ne pouvez pas directement coller des images. Envoyez-les depuis votre ordinateur ou insérez-les depuis une URL.

  • En ligne récemment   0 membre est en ligne

    • Aucun utilisateur enregistré regarde cette page.
×
×
  • Créer...