Verif de code php

Bonjour,

J'ai un petit problème de mon code il n'affiche pas les tableau que je lui demande je pense que c'est une de mes conditions qui ne fonctionne pas mais je ne voit pas pourquoi

je vous met mon code pour voir si quelqu'un de plus doué que moi pourait me débloquer svp

merci d'avance.

<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<link rel="stylesheet" media="screen" type="text/css" title="Design" href="style5.css" />
<title></title>
</head>
<body>
<div id="underlinemenu">
<ul>
<li><a href="nouveau_result_class.html" title="Nouveau_résultat">Nouveau résultat</a></li>
<li><a href="resultat.php" title="Palmarès">Palmarès</a></li>
<li><a href="simulation.html" title="Simulation">Simulation</a></li>
<li><a href="stat_class.html" title="Statistiques">Statistiques</a></li>
<li><a href="export_class.html" title="Export">Export</a></li>
</ul>
</div>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<?php

include("connect.php");

//Mise en forme et présentation de base

$login=$_SESSION['login'];

$sql = "SELECT NOM FROM PERSONNES P, COMPTE_UTILISATEUR C WHERE P.LICENCE = C.LICENCE AND C.LOGIN = '".addslashes($login)."'";
$req = mysql_query($sql) or die('Erreur SQL : <br />'.$sql);
$result = mysql_fetch_row($req);
$_SESSION['nom'] = $result[0];

$sql1 = "SELECT PRENOM FROM PERSONNES P, COMPTE_UTILISATEUR C WHERE P.LICENCE = C.LICENCE AND C.LOGIN = '".addslashes($login)."'";
$req1 = mysql_query($sql1) or die('Erreur SQL : <br />'.$sql1);
$result2 = mysql_fetch_row($req1);
$_SESSION['prenom'] = $result2[0];

echo $_SESSION['prenom'] . " " . $_SESSION['nom'] . "<br />" . "<br />";
echo 'PALMARES : '. date('Y') ."<br>"."<br>"."<br>";

//début du code pour la présentation des résultats

if (isset ($_POST['title']) && isset ($_POST['type']) )
{
$title = $_POST['title'];
$type = $_POST['type'];
$surface = $_POST['surface'];
$datedeb = $_POST['dateStartYear']."-".$_POST['dateStartMonth']."-".$_POST['dateStartDay'];
$datefin = $_POST['dateEndYear']."-".$_POST['dateEndMonth']."-".$_POST['dateEndDay'];

if (($_POST['win'])=='1')
{
$win = 'oui';
}
else
{
$win = 'non';
}
$requete1 = "insert into TOURNOI (`INTITULE`, `TYPE`, `SURFACE`, `DATE_DÉBUT`, `DATE_FIN`, `TOURNOI_REMPORTE`) values('$title','$type','$surface','$datedeb','$datefin','$win')";
mysql_query($requete1);

//requête pour insérer les tuples dans PARTICIPER
$req_array1 = mysql_query('SELECT LICENCE FROM PERSONNES');
$personnes = mysql_fetch_array($req_array1);
$personnes_licence = $personnes['LICENCE'];

//insertion des clés étrangères dans PARTICIPER
$requete2 = "insert into PARTICIPER (`INTITULE`, `LICENCE`) values('$title','$personnes_licence')";
mysql_query($requete2);
}

//mise en forme du tableau tournoi
$nom = $_SESSION['nom'];
$prenom = $_SESSION['prenom'];
$req_array2 = mysql_query("SELECT T.INTITULE,T.TYPE,T.SURFACE, T.DATE_DÉBUT, T.DATE_FIN, T.TOURNOI_REMPORTE FROM TOURNOI T, PARTICIPER PA, PERSONNES PE WHERE T.INTITULE = PA.INTITULE AND PA.LICENCE = PE.LICENCE AND PE.NOM = 'Lelais' AND PE.PRENOM = 'Sébastien'");
while ($epreuves = mysql_fetch_array($req_array2))
{?>
<table style="text-align: left; width: 966px; height: 32px;"
border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="background-color: rgb(192, 192, 192);"><span
style="color: rgb(255, 255, 255);"><?php
echo "<b>".$epreuves['INTITULE']." - Du ".$epreuves['DATE_DÉBUT']." au ".$epreuves['DATE_FIN']. " - ".$epreuves['SURFACE']."</b>"."<br>";
if ($epreuves['TOURNOI_REMPORTE']=='oui')
{
echo "Tournoi remporté";
}
?><span
style="font-weight: bold;"></span></span></td>
</tr>
</tbody>
</table>
<table style="text-align: left; width: 966px; height: 32px;"
border="1" cellpadding="2" cellspacing="2">
<tbody>
<?php
}
$eprId = $_POST['eprId'];
$dateresult = $_POST['dateYear']."-".$_POST['dateMonth']."-".$_POST['dateDay'];
$result = $_POST['result'];
$wo = $_POST['wo'];
$advClt = $_POST['advClt'];
$scoreSet1a = $_POST['scoreSet1a'];
$scoreSet1b = $_POST['scoreSet1b'];
$scoreSet2a = $_POST['scoreSet2a'];
$scoreSet2b = $_POST['scoreSet2b'];
$scoreSet3a = $_POST['scoreSet3a'];
$scoreSet3b = $_POST['scoreSet3b'];
$tour = $_POST['tour'];
$surface = $_POST['surface'];
$indoor = $_POST['indoor'];
$chpt = $_POST['chpt'];
$format = $_POST['format'];
$time = $_POST['time'];
$licence = $_POST['licence'];
$advLastName = $_POST['advLastName'];
$advFirstName = $_POST['advFirstName'];
$advNais = $_POST['advNais'];
$advClub = $_POST['advClub'];

//insertion dans la table matchs
if (isset ($_POST['eprId']) && isset ($_POST['result']) && isset ($_POST['advClt']) )
{
include("connect.php");

if ($indoor=='0' && $wo=='0' && $result=='D')
{
$indoor = 'extérieur';
$wo = 'wo';
$result = 'défaite';
}
else
{
$indoor = 'intérieur';
$wo = 'non';
$result = 'victoire';
}
$requete1 = "insert into MATCHS (`NUM_RESULTAT`, `INTITULE`, `DATE`, `RESULTAT`, `CLASSEMENT`, `SCORE_1_SET`, `SCORE_2_SET`, `SCORE_3_SET`, `TOUR`, `FORMAT`, `DURÉE`, `INDOOR`, `WO`) values('','$eprId','$dateresult','$result','$advClt','$scoreSet1a / $scoreSet1b','$scoreSet2a / $scoreSet2b','$scoreSet3a / $scoreSet3b','$tour','$format','$time','$indoor','$wo')";
mysql_query($requete1);
$requete2 = "insert into PERSONNES (`LICENCE`, `LICENCE_JOUER`, `NOM`, `PRENOM`, `NAISSANCE`, `NUM_CLUB`, `CLASSEMENT`, `SEXE`, `MAIL`) values('$licence','','$advLastName','$advFirstName','$advNais','$advClub','$advClt','','')";
mysql_query($requete2);
}

//mise en forme des résultats

$req_array3 = mysql_query("SELECT * FROM MATCHS M, TOURNOI T, PARTICIPER PA, PERSONNES PE WHERE M.INTITULE =T.INTITULE AND T.INTITULE = PA.INTITULE AND PA.LICENCE = PE.LICENCE AND PE.NOM = '".addslashes($nom)."' AND PE.PRENOM = '".addslashes($prenom)."'");
while ($matchs = mysql_fetch_array($req_array3))
{
if ($matchs['NUM_RESULTAT']='' && $matchs['INTITULE']='' && $matchs['RESULTAT']='' && $matchs['CLASSEMENT']='')
{?>
<tr>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Date</td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Tour</td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Adversaire</td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Clt</td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Score</td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Licence</td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Club</td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Age</td>
</tr><tr>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;"></td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;"></td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;"></td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Aucun résultat</td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;"></td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;"></td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;"></td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;"></td>
</tr>
</tbody>
</table>
<?php
}
else
{
?>
<table style="text-align: left; width: 966px; height: 32px;"
border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Date</td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Tour</td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Adversaire</td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Clt</td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Score</td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Licence</td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Club</td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;">Age</td>
</tr>
<tr>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;"><?php echo $matchs['DATE']?></td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;"><?php echo $matchs['TOUR']?></td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;"><?php echo $personnes['NOM']. " ".$personnes['PRENOM']?></td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;"><?php echo $matchs['CLASSEMENT']?></td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;"><?php echo $matchs['SCORE_1_SET']. " " .$matchs['SCORE_2_SET']. " ".$matchs['SCORE_3_SET']?></td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;"><?php echo $personnes['LICENCE']?></td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;"><?php echo $personnes['NUM_CLUB']?></td>
<td
style="text-align: center; background-color: rgb(205, 205, 205); color: rgb(51, 51, 255); font-weight: bold;"><?php echo date("Y") -$personnes['NAISSANCE']?></td>
</tr>
</tbody>
</table>
<?php
}
}
?>

</body>
</html>
Configuration: Windows Vista
Internet Explorer 7.0

12 réponses

  1. pardon voici le mld dema base

    Compte_utilisateur (login,mdp,licence)
    cp = login
    ce = licence qui reference Personnes.licence

    Personnes(licence,nom,prenom,naissance,num_club,classement,s­­exe,mail,licence_jouer)
    cp = licence
    ce = licence_jouer qui reference personnes.licence

    Tournoi (intitule,type,surface,date_début,date_fin,tournoi remporte)
    cp = intitule

    Matchs (num_resultat,intitule,date,resultat,classement,score_1_set,­­score_2_set,score_3_set,tour,format,durée,format,wo)
    cp = num_resultat
    ce = intitule qui reference Tournoi.intitule

    Participer (intitulé,licence)
    cp = (licence,intitulé)
    ce = licence qui reference Tournoi.intitulé
    ce = licence qui reference Personnes.licence
    1. up
      1. WHERE P.NOM = (select NOM
        from PERSONNES P,MATCHS M
        where P.LICENCE = M.ADVERSAIRE)

        est-ce que ça peut te retourner plusieurs noms? Remplace par des like les deux = précedant une sous-requete...
        C'est surement pas ça mais vu qu'on a pas tes tables, c'est chaud de t'aider.
    2. pas bête du tout ca lol par contre j'ai un nouveau problème lol je suis désolé

      Warning: mysql_query() [function.mysql-query]: Unable to save result set in /mnt/104/sdb/7/8/site.inter/TC_Besseen/Classement/resultat.php on line 185

      Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /mnt/104/sdb/7/8/site.inter/TC_Besseen/Classement/resultat.php on line 186

      $req_array3 = mysql_query(" SELECT M.DATE, M.TOUR, M.CLASSEMENT, M.SCORE_1_SET, M.SCORE_2_SET, M.SCORE_3_SET, P.NOM, P.LICENCE, P.NUM_CLUB
      FROM PERSONNES P, MATCHS M
      WHERE P.NOM = (select NOM
      from PERSONNES P,MATCHS M
      where P.LICENCE = M.ADVERSAIRE)
      AND M.INTITULE IN (
      SELECT INTITULE
      FROM PARTICIPER
      WHERE LICENCE = (
      SELECT LICENCE
      FROM PERSONNES
      WHERE NOM = '".$nom."'
      AND PRENOM = '".$prenom."')
      )");
      while ($matchs = mysql_fetch_array($req_array3))
      {
      if ($matchs['NUM_RESULTAT']='' && $matchs['INTITULE']='' && $matchs['RESULTAT']='' && $matchs['CLASSEMENT']='')
      {
      1. ok j'ai compris jvien de modifier merci

        par contre je voudrais tester quand la table est vide et donc je fais un

        if ($matchs['NUM_RESULTAT']='' && $matchs['INTITULE']='' && $matchs['RESULTAT']='' && $matchs['CLASSEMENT']='')

        en ayant fait une boucle while auparavant

        mais ca nefonctionne pas en faite je passe direct dans le else donc auriez vous une subtilité svp?
        1. Bonsoir,

          pour savoir si une table est vide, il suffit de compter combien elle contient d'enregistrements:

          $query = "SELECT count(*) from MATCHS";
          $result = mysql_query($query) or die (mysql_error());
          
          $row=mysql_fetch_row($result);
          
          $nb_enregistrements=$row[0]; //nombres d'enr dans la table MATCHS
          
          
          // ensuite:
          
          if($nb_enregistrements == 0 )   //elle est vide
          
          
      2. "$req_array1 doit surement te renvoier plus d'un résultat alors il faut les traiter par une boucle while
        par ce que toi tu ne traite qu'un seul par $personnes = mysql_fetch_array($req_array1);" a dit Alain_42

        ->Tu ne traiteras en effet que le premier résultat renvoyé.

        Si tu fais
        while ($personnes = mysql_fetch_array($req_array1))
        {
        $personnes_licence = $personnes['LICENCE'];
        }
        Tu ne traiteras que le dernier résultat renvoyé. Par exemple si $personnes['LICENCE']; = 1 au premier passage, 2 au deuxième passage et 3 au 3 ième passage, $personnes_licence vaudra 3. Et les deux premiers résultats seront"perdus"/pas pris en compte.
        1. je suis totalement bloqué la meme perdu je devrais dre lol
          1. en faisant ca vous voulez dire alain?

            while ($personnes = mysql_fetch_array($req_array1))
            {
            $personnes_licence = $personnes['LICENCE'];
            }

            sinon je pense qu'il y a un problème lors du prochain while aussi. vous ne pensez pas?
            sinon ce son dans les if après
            1. si tu fais juste ça, tu auras seulement le dernier résultat dans $personnes_licence, il faut exécuter ton traitement à l'intérieur du while.
          2. non les balises php ne génent pas

            par contre à première lecture je vois un pb:

            //requête pour insérer les tuples dans PARTICIPER
            $req_array1 = mysql_query('SELECT LICENCE FROM PERSONNES');
            $personnes = mysql_fetch_array($req_array1);
            $personnes_licence = $personnes['LICENCE'];

            //insertion des clés étrangères dans PARTICIPER
            $requete2 = "insert into PARTICIPER (`INTITULE`, `LICENCE`) values('$title','$personnes_licence')";
            mysql_query($requete2);


            $req_array1 doit surement te renvoier plus d'un résultat alors il faut les traiter par une boucle while

            par ce que toi tu ne traite qu'un seul par $personnes = mysql_fetch_array($req_array1);
            1. Bonsoir dans ta boucle while:

              while ($epreuves = mysql_fetch_array($req_array2))
              {?>
              <table style="text-align: left; width: 966px; height: 32px;"
              border="0" cellpadding="2" cellspacing="2">
              <tbody>
              <tr>
              <td style="background-color: rgb(192, 192, 192);"><span
              style="color: rgb(255, 255, 255);"><?php

              tu ne dois pas fermé tes balises php a mon avis . fais plutot un echo et enleve les ?> et le <?php

              ;)