Problème d'affichage
mike
-
Pitet Messages postés 2826 Date d'inscription Statut Membre Dernière intervention -
Pitet Messages postés 2826 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Je suis nouveau dans le php et j'ai developpé une appli qui marche mais qui a quelque problème.
lorsque je lance la liste des achats, il affiche tous les achats sur 10 enregistrements et quand je clic sur le bouton suivant pour les enregistrements suivants en ce moment il affiche des messages d'erreur
( ! ) Notice: Undefined variable: note in C:\wamp\www\suremanager\rapportachat1.php on line 104
Call Stack
# Time Memory Function Location
1 0.0031 431472 {main}( ) ..\rapportachat1.php:0
Produit Acheté Qté Acheté (Kg) Nbre Sacs Date d'Achat Nom Pisteur Nom Paysan
( ! ) Notice: Undefined variable: rek in C:\wamp\www\suremanager\rapportachat1.php on line 108
Call Stack
# Time Memory Function Location
1 0.0031 431472 {main}( ) ..\rapportachat1.php:0
( ! ) Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\suremanager\rapportachat1.php on line 111
Call Stack
# Time Memory Function Location
1 0.0031 431472 {main}( ) ..\rapportachat1.php:0
2 0.0281 740928 mysql_num_rows ( )
..\rapportachat1.php:111
Aucun Achat Effectué à cette période
aidez moi à resoudre ce problème svp
Je suis nouveau dans le php et j'ai developpé une appli qui marche mais qui a quelque problème.
lorsque je lance la liste des achats, il affiche tous les achats sur 10 enregistrements et quand je clic sur le bouton suivant pour les enregistrements suivants en ce moment il affiche des messages d'erreur
( ! ) Notice: Undefined variable: note in C:\wamp\www\suremanager\rapportachat1.php on line 104
Call Stack
# Time Memory Function Location
1 0.0031 431472 {main}( ) ..\rapportachat1.php:0
Produit Acheté Qté Acheté (Kg) Nbre Sacs Date d'Achat Nom Pisteur Nom Paysan
( ! ) Notice: Undefined variable: rek in C:\wamp\www\suremanager\rapportachat1.php on line 108
Call Stack
# Time Memory Function Location
1 0.0031 431472 {main}( ) ..\rapportachat1.php:0
( ! ) Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\suremanager\rapportachat1.php on line 111
Call Stack
# Time Memory Function Location
1 0.0031 431472 {main}( ) ..\rapportachat1.php:0
2 0.0281 740928 mysql_num_rows ( )
..\rapportachat1.php:111
Aucun Achat Effectué à cette période
aidez moi à resoudre ce problème svp
A voir également:
- Problème d'affichage
- Affichage double ecran - Guide
- Problème affichage fenêtre windows 10 - Guide
- Windows 11 affichage classique - Guide
- Problème affichage page internet google chrome - Forum Téléphones & tablettes Android
- Pinterest problème affichage ✓ - Forum Réseaux sociaux
4 réponses
voici mon code source:
<?php
session_start();
include('sql/sqlconnect.php');
include('sql/sqlfonction.php');
global $nbre;
if(isset($_GET['fin'])){
$fin=$_GET['fin'];
}
else{$fin=$nbre;}
if(isset($_GET['deb'])){
$deb=$_GET['deb'];
}
else{$deb=0;}
if(isset($_GET['err'])){
$err=$_GET['err'];
}
/*
si la variable de session login n'existe pas cela siginifie que le visiteur
n'a pas de session ouverte, il n'est donc pas logué ni autorisé Ã
acceder à l'espace membres
*/
if(!isset($_SESSION['login'])) {
echo '<div align=\'center\'>Vous n\'êtes pas autorisé à acceder à cette zone</div>';
include('index.php');
exit;
}
?>
<?php
$title="Achat Effectués par Localité";
commonheader_in($title,300);
/*
?>
<!-- Add some javascript content here -->
<?php
*/
commonheader_out();
//print_r($_POST);
//print_r($SERVER);
?>
<?php
//$id_magasin= '';
$id_magasin=$_POST['id_magasin'];
if($id_magasin!=0){
$rek="select * from achat,pisteur,magasin where magasin.id_magasin='$id_magasin' and pisteur.id_pisteur=achat.id_pisteur and magasin.id_magasin=achat.id_magasin";
}
else{
$rek="select * from achat,pisteur,magasin where pisteur.id_pisteur=achat.id_pisteur and magasin.id_magasin=achat.id_magasin";
}
// echo $rek; exit;
if(isset($_POST['periode'])){
$periode=$_POST['periode'];
if ($periode == 2) {
$annee=$_POST['annee'];
$mois=$_POST['mois'];
if (!empty($mois)) {
$mois=$mois+1;
}
//$jours=$_POST['jours'];
}
}
if(isset($_POST['periode'])){
$periode=$_POST['periode'];
switch ($periode)
{
case 0:// Aujourd'hui
$today=date('Y-m-d');
//$today=date('2008-3-7');
$rek.=" and achat.date_achat='$today' ";
if(isset($_POST['note'])){
$note=$_POST['note'];}
$note="Aujourd'hui";
break;
case 1:// Cette Semaine
$sem=semaine_courante();
$datedeb=$sem[0];
$datefin=$sem[1];
$rek.=" and achat.date_achat>='$datedeb' and achat.date_achat<='$datefin' ";
if(isset($_POST['note'])){
$note=$_POST['note'];}
$note="Semaine courante";
break;
case 2:// Autre = Date é Préciser
// pour le moment je met empty jour
$jours="";
if ( empty($jours) ) {
if ( empty($mois) ) {
$rek.=" and achat.date_achat>='$annee-01-01' and achat.date_achat<='$annee-12-31' ";
$note="Année : <b>$annee<b>";
} else {
$rek.=" and achat.date_achat>='$annee-$mois-01' and achat.date_achat<='$annee-$mois-31' ";
if(isset($_POST['note'])){
$note=$_POST['note'];}
$note="Mois : <b>$mois-$annee<b>";
}
}
break;
}
}
$re=mysql_query("select nom_magasin from magasin where magasin.id_magasin='$id_magasin'");
$ta=mysql_fetch_array($re);
?>
<h1>Achats Effectués pour <?php echo " ".$ta['nom_magasin']; ?></h1>
<table align="center" class="tab_cadre">
<tr class="tab_bg_1"><td align="center" colspan="6">
<?php
echo $note;
?>
</td></tr>
<tr class="tab_bg_1"><TD align="center">Produit Acheté</TD><TD align="center">Qté Acheté (Kg)</TD> <td align="center">Nbre Sacs</TD><td align="center">Date d'Achat</TD><TD align="center">Nom Pisteur</TD><TD align="center">Nom Paysan</TD></tr>
<?php
$rek.=" ORDER BY achat.id_achat DESC ";
//echo $rek;
$resco=mysql_query($rek);
$res=ymysql_query($rek,$deb,$nbre); //echo $rek; exit;
$result=mysql_num_rows($resco);
if($result){
while($tab=mysql_fetch_array($res)){
$prdt_achat=$tab['prdt_achat'];
$qte_achat=$tab['qte_achat'];
$nbre_sac=$tab['nbre_sac'];
$date_achat=$tab['date_achat'];
$date_achat=date("d-m-Y", strtotime($date_achat));
//$dateaffiche=$date('d-m-Y');
$pisteur=$tab['id_pisteur'];
$pist=id2namepisteur($pisteur);
$nom_paysan=$tab['nom_paysan'];
echo "<tr class='tab_bg_2' align='left'><td align='left'>$prdt_achat</td><td align='center'>$qte_achat</td><td align='center'>$nbre_sac</td><td align='center'>$date_achat</td><td align='left'>$pist</td><td align='left'>$nom_paysan</td></tr>";
}
}else{
echo "<tr class='tab_bg_3' align='center'><td colspan='6'><h2>Aucun Achat Effectué à cette période</h2></td></tr>";
}
?>
<tr align="center">
<td colspan="6" align="center">
<?php
if ($result!=0){
if ($result>$nbre-1){?>
(Enregistrement de <?php echo $deb+1;?> à <?php echo $fin;?> sur <?php echo $result?>)
<?php }else
{
if (($result<=$nbre-1) && ($result>0)){?>
(Enregistrement de 1 à <?php echo $result?>)
<?php }else
{?>
(Pas d'enregistrement)
<?php }}
if($result>$nbre)
{
?>
<a title="Première Page" href="rapachatmag1.php?deb=0&fin=<?php echo $nbre;?>"><img src="./images/first.png" alt="premier" border="0"></a> premier
<?php
$dif=$deb-$nbre;
if($dif >=0){?>
<a title="Page Prédente" href="rapachatmag1.php?deb=<?php echo $deb -$nbre;?>&fin=<?php echo $deb;?>"><img src="./images/prev.png" alt="precedent" border="0"></a> precedent
<?php }
else{?><a title="debut de page"><img src="./images/prev.png" alt="precedent" border="0"> precedent </a><?php }?>
<?php $dif=$result-$fin;
if( $dif >=$nbre){?>
<a title="Page Suivante" href="rapachatmag1.php?deb=<?php echo $fin;?>&fin=<?php echo $fin+$nbre;?>"><img src="./images/next.png" alt="suivant" border="0"></a> suivant
<?php } else
if(( $dif >0) &&($dif<$nbre)){?><a title="Page Suivante" href="rapachatmag1.php?deb=<?php echo $fin;?>&fin=<?php echo $fin+$dif;?>"><img src="./images/next.png" alt="suivant" border="0"></a> suivant
<?php }else{?><a title="Fin de page"><img src="./images/next.png" alt="suivant" border="0"> suivant </a><?php }?>
<?php $dif=$result-$nbre;
if( $dif >=0){
if(($dif % $nbre)==0){?>
<a title="Dernière Page" href="rapachatmag1.php?deb=<?php echo $result -$nbre;?>&fin=<?php echo $result;?>"><img src="./images/last.png" alt="dernier" border="0"></a> dernier
<?php }else{ ?><a title="Dernière Page" href="rapachatmag1.php?deb=<?php echo $result -$nbre+1;?>&fin=<?php echo $result;?>"><img src="./images/last.png" alt="dernier" border="0"></a> dernier
<?php }
}
else
{
?><a title="Fin de page"><img src="./images/last.png" alt="dernier" border="0"> dernier </a><?php }?>
<?php }
else
{
?>
<a title="Première Page"><img src="./images/first.png" alt="premier" border="0"></a> premier
<a title="debut de page"><img src="./images/prev.png" alt="precedent" border="0"> precedent </a>
<a title="Fin de page"><img src="./images/next.png" alt="suivant" border="0"> suivant </a>
<a title="Dernière Page"><img src="./images/last.png" alt="dernier" border="0"></a> dernier
<?php }
}
?>
</TD></tr>
</table>
<?php commonfooter();?>
<?php
session_start();
include('sql/sqlconnect.php');
include('sql/sqlfonction.php');
global $nbre;
if(isset($_GET['fin'])){
$fin=$_GET['fin'];
}
else{$fin=$nbre;}
if(isset($_GET['deb'])){
$deb=$_GET['deb'];
}
else{$deb=0;}
if(isset($_GET['err'])){
$err=$_GET['err'];
}
/*
si la variable de session login n'existe pas cela siginifie que le visiteur
n'a pas de session ouverte, il n'est donc pas logué ni autorisé Ã
acceder à l'espace membres
*/
if(!isset($_SESSION['login'])) {
echo '<div align=\'center\'>Vous n\'êtes pas autorisé à acceder à cette zone</div>';
include('index.php');
exit;
}
?>
<?php
$title="Achat Effectués par Localité";
commonheader_in($title,300);
/*
?>
<!-- Add some javascript content here -->
<?php
*/
commonheader_out();
//print_r($_POST);
//print_r($SERVER);
?>
<?php
//$id_magasin= '';
$id_magasin=$_POST['id_magasin'];
if($id_magasin!=0){
$rek="select * from achat,pisteur,magasin where magasin.id_magasin='$id_magasin' and pisteur.id_pisteur=achat.id_pisteur and magasin.id_magasin=achat.id_magasin";
}
else{
$rek="select * from achat,pisteur,magasin where pisteur.id_pisteur=achat.id_pisteur and magasin.id_magasin=achat.id_magasin";
}
// echo $rek; exit;
if(isset($_POST['periode'])){
$periode=$_POST['periode'];
if ($periode == 2) {
$annee=$_POST['annee'];
$mois=$_POST['mois'];
if (!empty($mois)) {
$mois=$mois+1;
}
//$jours=$_POST['jours'];
}
}
if(isset($_POST['periode'])){
$periode=$_POST['periode'];
switch ($periode)
{
case 0:// Aujourd'hui
$today=date('Y-m-d');
//$today=date('2008-3-7');
$rek.=" and achat.date_achat='$today' ";
if(isset($_POST['note'])){
$note=$_POST['note'];}
$note="Aujourd'hui";
break;
case 1:// Cette Semaine
$sem=semaine_courante();
$datedeb=$sem[0];
$datefin=$sem[1];
$rek.=" and achat.date_achat>='$datedeb' and achat.date_achat<='$datefin' ";
if(isset($_POST['note'])){
$note=$_POST['note'];}
$note="Semaine courante";
break;
case 2:// Autre = Date é Préciser
// pour le moment je met empty jour
$jours="";
if ( empty($jours) ) {
if ( empty($mois) ) {
$rek.=" and achat.date_achat>='$annee-01-01' and achat.date_achat<='$annee-12-31' ";
$note="Année : <b>$annee<b>";
} else {
$rek.=" and achat.date_achat>='$annee-$mois-01' and achat.date_achat<='$annee-$mois-31' ";
if(isset($_POST['note'])){
$note=$_POST['note'];}
$note="Mois : <b>$mois-$annee<b>";
}
}
break;
}
}
$re=mysql_query("select nom_magasin from magasin where magasin.id_magasin='$id_magasin'");
$ta=mysql_fetch_array($re);
?>
<h1>Achats Effectués pour <?php echo " ".$ta['nom_magasin']; ?></h1>
<table align="center" class="tab_cadre">
<tr class="tab_bg_1"><td align="center" colspan="6">
<?php
echo $note;
?>
</td></tr>
<tr class="tab_bg_1"><TD align="center">Produit Acheté</TD><TD align="center">Qté Acheté (Kg)</TD> <td align="center">Nbre Sacs</TD><td align="center">Date d'Achat</TD><TD align="center">Nom Pisteur</TD><TD align="center">Nom Paysan</TD></tr>
<?php
$rek.=" ORDER BY achat.id_achat DESC ";
//echo $rek;
$resco=mysql_query($rek);
$res=ymysql_query($rek,$deb,$nbre); //echo $rek; exit;
$result=mysql_num_rows($resco);
if($result){
while($tab=mysql_fetch_array($res)){
$prdt_achat=$tab['prdt_achat'];
$qte_achat=$tab['qte_achat'];
$nbre_sac=$tab['nbre_sac'];
$date_achat=$tab['date_achat'];
$date_achat=date("d-m-Y", strtotime($date_achat));
//$dateaffiche=$date('d-m-Y');
$pisteur=$tab['id_pisteur'];
$pist=id2namepisteur($pisteur);
$nom_paysan=$tab['nom_paysan'];
echo "<tr class='tab_bg_2' align='left'><td align='left'>$prdt_achat</td><td align='center'>$qte_achat</td><td align='center'>$nbre_sac</td><td align='center'>$date_achat</td><td align='left'>$pist</td><td align='left'>$nom_paysan</td></tr>";
}
}else{
echo "<tr class='tab_bg_3' align='center'><td colspan='6'><h2>Aucun Achat Effectué à cette période</h2></td></tr>";
}
?>
<tr align="center">
<td colspan="6" align="center">
<?php
if ($result!=0){
if ($result>$nbre-1){?>
(Enregistrement de <?php echo $deb+1;?> à <?php echo $fin;?> sur <?php echo $result?>)
<?php }else
{
if (($result<=$nbre-1) && ($result>0)){?>
(Enregistrement de 1 à <?php echo $result?>)
<?php }else
{?>
(Pas d'enregistrement)
<?php }}
if($result>$nbre)
{
?>
<a title="Première Page" href="rapachatmag1.php?deb=0&fin=<?php echo $nbre;?>"><img src="./images/first.png" alt="premier" border="0"></a> premier
<?php
$dif=$deb-$nbre;
if($dif >=0){?>
<a title="Page Prédente" href="rapachatmag1.php?deb=<?php echo $deb -$nbre;?>&fin=<?php echo $deb;?>"><img src="./images/prev.png" alt="precedent" border="0"></a> precedent
<?php }
else{?><a title="debut de page"><img src="./images/prev.png" alt="precedent" border="0"> precedent </a><?php }?>
<?php $dif=$result-$fin;
if( $dif >=$nbre){?>
<a title="Page Suivante" href="rapachatmag1.php?deb=<?php echo $fin;?>&fin=<?php echo $fin+$nbre;?>"><img src="./images/next.png" alt="suivant" border="0"></a> suivant
<?php } else
if(( $dif >0) &&($dif<$nbre)){?><a title="Page Suivante" href="rapachatmag1.php?deb=<?php echo $fin;?>&fin=<?php echo $fin+$dif;?>"><img src="./images/next.png" alt="suivant" border="0"></a> suivant
<?php }else{?><a title="Fin de page"><img src="./images/next.png" alt="suivant" border="0"> suivant </a><?php }?>
<?php $dif=$result-$nbre;
if( $dif >=0){
if(($dif % $nbre)==0){?>
<a title="Dernière Page" href="rapachatmag1.php?deb=<?php echo $result -$nbre;?>&fin=<?php echo $result;?>"><img src="./images/last.png" alt="dernier" border="0"></a> dernier
<?php }else{ ?><a title="Dernière Page" href="rapachatmag1.php?deb=<?php echo $result -$nbre+1;?>&fin=<?php echo $result;?>"><img src="./images/last.png" alt="dernier" border="0"></a> dernier
<?php }
}
else
{
?><a title="Fin de page"><img src="./images/last.png" alt="dernier" border="0"> dernier </a><?php }?>
<?php }
else
{
?>
<a title="Première Page"><img src="./images/first.png" alt="premier" border="0"></a> premier
<a title="debut de page"><img src="./images/prev.png" alt="precedent" border="0"> precedent </a>
<a title="Fin de page"><img src="./images/next.png" alt="suivant" border="0"> suivant </a>
<a title="Dernière Page"><img src="./images/last.png" alt="dernier" border="0"></a> dernier
<?php }
}
?>
</TD></tr>
</table>
<?php commonfooter();?>
Utilisateur anonyme
Merci, peux tu modifier ton post en utilisant la balise code / php proposée, ainsi nous aurons les numeros de ligne .... parceque la ca arrache un peu les yeux ^^
qd je mets le @ devant la variable , il n'affiche pas le contenu e la variable et la requete en question n'affiche rien
alors que pour les dix premier enregistrements il n' y a pas de problèe.
Il affiche tous les dix enregistrements selon les dates choisies par l'utilisateur.
le problème c'est au niveau des enregistrements suivants; il n'affiche pas la page suivantes comme il se doit.
comme si la date qu'il recupere dans une autre page ne fonctionne pas
alors que pour les dix premier enregistrements il n' y a pas de problèe.
Il affiche tous les dix enregistrements selon les dates choisies par l'utilisateur.
le problème c'est au niveau des enregistrements suivants; il n'affiche pas la page suivantes comme il se doit.
comme si la date qu'il recupere dans une autre page ne fonctionne pas
pour le @ tu ne dois pas avoir cherché bien loin ...
https://www.developpez.net/forums/d40379/php/langage/securite-devant-fonction/
mais avant tout presente nous ton code comme du PHP en modifiant ton post ...............
https://www.developpez.net/forums/d40379/php/langage/securite-devant-fonction/
mais avant tout presente nous ton code comme du PHP en modifiant ton post ...............
Salut,
Pour ta première erreur, tu affiche la variable ligne 104 alors qu'elle n'existe pas au premier chargement de la page (ajouter un if(isset($_POST['note'])) avant le echo).
Pour la deuxième erreur, au premier chargement tu concatènes une variable non initialisé ligne 108.
Ta 3e erreur indique que ta requête sql n'est pas correct, surement une erreur de syntaxe.
Bonne journée
Pour ta première erreur, tu affiche la variable ligne 104 alors qu'elle n'existe pas au premier chargement de la page (ajouter un if(isset($_POST['note'])) avant le echo).
Pour la deuxième erreur, au premier chargement tu concatènes une variable non initialisé ligne 108.
Ta 3e erreur indique que ta requête sql n'est pas correct, surement une erreur de syntaxe.
Bonne journée