Problème récupération d'une variable

Résolu/Fermé
shishi1906 Messages postés 93 Date d'inscription mercredi 1 mai 2013 Statut Membre Dernière intervention 27 mars 2014 - 12 juin 2013 à 10:10
shishi1906 Messages postés 93 Date d'inscription mercredi 1 mai 2013 Statut Membre Dernière intervention 27 mars 2014 - 12 juin 2013 à 11:46
Bonjour,

Je vous explique mon soucis.
J'ai 3 fichiers.

Un fichier (a) où je choisi le nom d'un utilisateur.
un fichier (b) où j'affiche son emploi du temps.
un fichier (c) qui contient les fonctions qui permette d'afficher l'emploi du temps.


Je voudrais que quand je selectionne le nom de mon utilisateur il me donne l'emploi du temps correspondant. Mais il me met que ma variable n'est pas définis alors que j'ai poster ma variable dans mon fichier (b).
Je ne comprend pas mon erreur quelqu'un pourrait-il m'aider ?

Fichier a :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
	
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<title>Csc : Plannings</title>
		<meta http-equiv="content-type" content="text/html;charset=utf-8" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<link rel="stylesheet" href="Css.css" type="text/css" />
	</head>
	<body>
		
		<center><h1>Centre SocioCulturel</h1></center>
		<center><h2>Point de Mire</h2></center>
		<center><h2>Plannings</h2></center>
		
		
		<ul class="menu" >
			<li><a href="index.html">Accueil</a></li>
			<li><a href="planning.php">Plannings</a></li>
			<li><a href="reservationSalle.php">Réservation des salles</a></li>
			<li><a href="reservationmateriel.php">Réservation matériel</a></li>
			<li><a href="reservationvehicule.php">Réservation d'un véhicule</a></li>
			<li><a href="connexion.php">Connexion </a></li>
		</ul></center><br />
		
		<form method="post" action="indexplanning.php">
			Séléctionner le salarié dont vous voulez le planning : <br />
			<select name="idsalarie">
				<option value="0">---------------</option>
				<?php
					// Connexion à la base de donnée
					$cnx = mysql_connect("localhost", "root", "") or die("Impossible de se connecter");
					
					// Selection de la base
					$db = mysql_select_db("csc_apli") or die("Impossible de se connecter");
					
					// Selection dans la base type_motif
					$requete5="SELECT * FROM salarie ORDER BY nom ASC";
					
					//Exécution de la requete
					$result5=mysql_query($requete5);
					
					//Selection de tous les champs
					while ($ligne=mysql_fetch_array($result5))
					{
					   echo '<OPTION VALUE="'.$ligne["IDSALARIE"].'">'.$ligne["NOM"].' '.$ligne["PRENOM"].'</OPTION>';
					}
				?>
			</select>
			
			<input type="submit" value="Valider" />
		</form>
	</body>
</html>


Fichier b :
<!DOCTYPE html>
<html>
    <head>
		</style>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Calendrier</title>
        <link rel="stylesheet" type="text/css" href="Css.css" />
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
        <script type="text/javascript">
            jQuery(function($){
               $('.month').hide();
               $('.month:first').show();
               $('.months a:first').addClass('active');
               var current = 1;
               $('.months a').click(function(){
                    var month = $(this).attr('id').replace('linkMonth','');
                    if(month != current){
                        $('#month'+current).slideUp();
                        $('#month'+month).slideDown();
                        $('.months a').removeClass('active'); 
                        $('.months a#linkMonth'+month).addClass('active'); 
                        current = month;
                    }
                    return false; 
               });
            });
        </script>
    </head>
    <body>
		<ul class="menu" >
			<li><a href="index.html">Accueil</a></li>
			<li><a href="indexplanning.php">Plannings</a></li>
			<li><a href="reservationSalle.php">Réservation des salles</a></li>
			<li><a href="reservationmateriel.php">Réservation matériel</a></li>
			<li><a href="reservationvehicule.php">Réservation d'un véhicule</a></li>
			<li><a href="connexion.php">Connexion </a></li>
		</ul>
	
        <?php 
		$idsalarie=$_POST['idsalarie'];
        require('date.php');
        $date = new Date();
        $year = date('Y'); 
        $events = $date->getEvents($year);
        $dates = $date->getAll($year);
        ?>
        <div class="periods">
            <div class="year"><?php echo $year; ?></div>
            <div class="months">
                <ul>
                    <?php foreach ($date->months as $id=>$m): ?>
                         <li><a href="#" id="linkMonth<?php echo $id+1; ?>"><?php echo utf8_encode(substr(utf8_decode($m),0,3)); ?></a></li>
                    <?php endforeach; ?>
                </ul>
            </div>
            <div class="clear"></div>
            <?php $dates = current($dates); ?>
            <?php foreach ($dates as $m=>$days): ?>
               <div class="month relative" id="month<?php echo $m; ?>">
               <table class="planning">
                   <thead>
                       <tr>
                           <?php foreach ($date->days as $d): ?>
                                <th><?php echo substr($d,0,3); ?></th>
                           <?php endforeach; ?>
                       </tr>
                   </thead>
                   <tbody>
                       <tr>
                       <?php $end = end($days); foreach($days as $d=>$w): ?>
                           <?php $time = strtotime("$year-$m-$d"); ?>
                           <?php if($d == 1 && $w != 1): ?>
                                <td colspan="<?php echo $w-1; ?>" class="padding"></td>
                           <?php endif; ?>
                           <td<?php if($time == strtotime(date('Y-m-d'))): ?> class="today" <?php endif; ?>>
                                <div class="relative">
                                    <div class="day"><?php echo $d; ?></div>
                                </div>
                               <div class="daytitle">
                                   <?php echo $date->days[$w-1]; ?> <?php echo $d; ?>  <?php echo $date->months[$m-1]; ?>
                               </div>
                               <ul class="events">
                                   <?php if(isset($events[$time])): foreach($events[$time] as $e): ?>
                                        <li><?php echo $e; ?></li>
                                   <?php endforeach; endif;  ?>
                               </ul>
                           </td>
                           <?php if($w == 7): ?>
                            </tr><tr>
                           <?php endif; ?>
                       <?php endforeach; ?>
                       <?php if($end != 7): ?>
                            <td colspan="<?php echo 7-$end; ?>" class="padding"></td>
                       <?php endif; ?>
                       </tr>
                   </tbody>
               </table>
               </div>
            <?php endforeach; ?>
        </div>
        <div class="clear"></div>
    </body>
</html>


fichier c:
<?php
	
class Date{

    var $days       = array('Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi','Dimanche');
    var $months     = array('Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre');

    function getEvents($year){
		// connexion à la base
		$base = mysql_connect ("localhost", "root", "") or die('Erreur de connexion '.mysql_error());
		
		// sélection de la base 
		mysql_select_db('csc_apli',$base)  or die('Erreur de selection '.mysql_error()); 
		
		$sql = sprintf('SELECT * FROM planning WHERE YEAR(date) ='.$year.' && IDSALARIE='.$idsalarie);
		
        $res=mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
		$r=array();
		$r2=array();
		$r3=array();
        /**
         * Ce que je veux $r[TIMESTAMP][id] = title
         */
		while($d=mysql_fetch_object($res)){

           $r[strtotime($d->date)][$d->id] = $d->libelle." ".$d->heuredebut." ".$d->heurefin;
		   //print_r($d);
		}
        return $r;
	}

    function getAll($year){
        $r = array();

        $date = strtotime($year.'-01-01');
        while(date('Y',$date) <= $year){
            // Ce que je veux => $r[ANEEE][MOIS][JOUR] = JOUR DE LA SEMAINE
            $y = date('Y',$date);
            $m = date('n',$date);
            $d = date('j',$date);
            $w = str_replace('0','7',date('w',$date));
            $r[$y][$m][$d] = $w;
            $date = strtotime(date('Y-m-d',$date).' +1 DAY');
        }
		/*
        $date = new DateTime($year.'-01-01');
        while($date->format('Y') <= $year){
            // Ce que je veux => $r[ANEEE][MOIS][JOUR] = JOUR DE LA SEMAINE
            $y = $date->format('Y');
            $m = $date->format('n');
            $d = $date->format('j');
            $w = str_replace('0','7',$date->format('w'));
            $r[$y][$m][$d] = $w;
            $date->add(new DateInterval('P1D'));
        }*/
        return $r; 
    }

}


Merci d'avance :)

1 réponse

shishi1906 Messages postés 93 Date d'inscription mercredi 1 mai 2013 Statut Membre Dernière intervention 27 mars 2014
12 juin 2013 à 11:46
Problème résolu
0