Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD
PHP & SGBD Forum d'entraide sur les SGBD avec PHP. Avant de poster : FAQ BDD, toutes les FAQ PHP, cours BDD et sources BDD
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 15/05/2006, 15h54   #1
Membre habitué
 
Inscription : janvier 2006
Messages : 344
Détails du profil
Informations forums :
Inscription : janvier 2006
Messages : 344
Points : 116
Points : 116
Par défaut [SQL] Affichage résultat requête dans un tableau, bouton affichage page

Salut,

j ai un formulaire PHP/mysql dans lequel j affiche le resultat d'une requete dans un tableau, j ai limité a l'affichage a 50 lignes et j ai créer des boutons << < > >> et j ai aussi une combobox avec les pages.

Mais quand je clique sur les boutons bien je reste toujours sur la meme page.

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
 
$maxrow=50;
/*echo maxrow;
echo $maxrow;
echo "<br>";
echo "<br>";*/
 
$result5 = $db->sql_query($sql5);
$numrows = $db->sql_numrows($result5);
/*echo $numrows;
echo "<br>";
echo "<br>";*/
$maxpage=round($numrows/$maxrow);
/*echo maxpage;
echo $maxpage;
echo "<br>";
echo "<br>";*/
 
  echo"<div align='center' name='btn'>";
  echo"<br>";
  echo"<br>";
  echo"<input type='button' name='first' value='<<' onclick='orders_list.php?pgno=0&orderby=OrderID'>";
  echo"<input type='button' name='before' value='<' onclick='orders_list.php?pgno=($pgno-1)&orderby=OrderID'>";
  echo"<input type='text' name='numpage' value='' >";
  echo"<input type='button' name='last' value='>' onclick='orders_list.php?pgno=($pgno+1)&orderby=OrderID'>";
  echo"<input type='button' name='last' value='>>' onclick='orders_list.php?pgno=($maxpage+1)&orderby=OrderID'>";
 
  echo"<select name='pages'>";
  for($i=1;$i<=($maxpage+1);$i++)
  {
   echo"<option value='$i' onchange='orders_list.php?pgno=(".$i.")&orderby=OrderID'>$i";
  }
  echo"</select>";
 
 
 
  echo"</div>";

je ne sais trop comment faire et pourquoi ca fonctionne pas

Si quelqu un a un tuyau ,un conseil merci
megapacman est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/05/2006, 16h08   #2
Expert Confirmé

 
Avatar de Amara
 
Inscription : juillet 2004
Messages : 2 684
Détails du profil
Informations personnelles :
Localisation : France, Sarthe (Pays de la Loire)

Informations forums :
Inscription : juillet 2004
Messages : 2 684
Points : 2 910
Points : 2 910
Salut,

Quand tu cliques sur les boutons il n'y a rien qui se passe ? Ou ta page est rafraîchie avec exactement la même adresse avec les mêmes paramètres ? Ou c'est l'affichage qui se fait toutjours pareil sans tenir compte des paramètres (dans ce cas montre le code de l'affichage) ?
Amara est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/05/2006, 16h13   #3
NoT
Membre confirmé
 
Inscription : février 2004
Messages : 237
Détails du profil
Informations forums :
Inscription : février 2004
Messages : 237
Points : 261
Points : 261
Citation:
onclick='orders_list.php?pgno=($pgno+1)&orderby=OrderID'
Ca me parait pas très correct, essai plutot un code du genre :

Code :
1
2
 
onclick='document.location=\"orders_list.php?pgno=($pgno+1)&orderby=OrderID\";'
NoT est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/05/2006, 16h17   #4
Membre habitué
 
Inscription : janvier 2006
Messages : 344
Détails du profil
Informations forums :
Inscription : janvier 2006
Messages : 344
Points : 116
Points : 116
Salut,

oui en fait quand je clique sur les boutons y a rien qui se passe


megapacman est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/05/2006, 16h21   #5
Membre habitué
 
Inscription : janvier 2006
Messages : 344
Détails du profil
Informations forums :
Inscription : janvier 2006
Messages : 344
Points : 116
Points : 116
j ai essayé comme ca

Code :
1
2
3
 
 
onclick='document.location=\"orders_list.php?pgno=($pgno+1)&orderby=OrderID\";'

la ca semble se rafraichir mais y a rien qui se passe

megapacman est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/05/2006, 16h24   #6
Membre habitué
 
Inscription : janvier 2006
Messages : 344
Détails du profil
Informations forums :
Inscription : janvier 2006
Messages : 344
Points : 116
Points : 116
petite précision , orders_list.php c'est la feuille en cours

merci
megapacman est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/05/2006, 16h30   #7
NoT
Membre confirmé
 
Inscription : février 2004
Messages : 237
Détails du profil
Informations forums :
Inscription : février 2004
Messages : 237
Points : 261
Points : 261
Code :
  echo"<input type='button' name='last' value='>' onclick='orders_list.php?pgno=($pgno+1)&orderby=OrderID'>";
($pgno+1) va pas être parsé à mon avis ,

à remplacer par :
Code :
1
2
 
 echo"<input type='button' name='last' value='>' onclick='orders_list.php?pgno=".($pgno+1)."&orderby=OrderID'>";
NoT est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/05/2006, 16h36   #8
Membre habitué
 
Inscription : janvier 2006
Messages : 344
Détails du profil
Informations forums :
Inscription : janvier 2006
Messages : 344
Points : 116
Points : 116
non toujours pareil
megapacman est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/05/2006, 16h40   #9
Expert Confirmé

 
Avatar de Amara
 
Inscription : juillet 2004
Messages : 2 684
Détails du profil
Informations personnelles :
Localisation : France, Sarthe (Pays de la Loire)

Informations forums :
Inscription : juillet 2004
Messages : 2 684
Points : 2 910
Points : 2 910
Regarde les URLs qui s'affichent avant et après rafraîchissement de ta page et vois si ça correspond à ce que tu veux. Si c'est le cas le problème vient peut-être de l'affichage des données, et tu nous as pas mis le code.
Amara est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/05/2006, 16h42   #10
NoT
Membre confirmé
 
Inscription : février 2004
Messages : 237
Détails du profil
Informations forums :
Inscription : février 2004
Messages : 237
Points : 261
Points : 261
Et la requête que tu utilises ressemble à quoi ? Tu utilises les variables $_GET['pgno'] et $_GET['orderby'] ?
NoT est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/05/2006, 17h54   #11
Membre habitué
 
Inscription : janvier 2006
Messages : 344
Détails du profil
Informations forums :
Inscription : janvier 2006
Messages : 344
Points : 116
Points : 116
oui, j utilise $_GET['orderby'] et $_GET['pgno']
megapacman est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/05/2006, 18h14   #12
Expert Confirmé

 
Avatar de Amara
 
Inscription : juillet 2004
Messages : 2 684
Détails du profil
Informations personnelles :
Localisation : France, Sarthe (Pays de la Loire)

Informations forums :
Inscription : juillet 2004
Messages : 2 684
Points : 2 910
Points : 2 910
Si tu réponds pas à tous les messages ça va pas être facile
Amara est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/05/2006, 08h59   #13
Membre habitué
 
Inscription : janvier 2006
Messages : 344
Détails du profil
Informations forums :
Inscription : janvier 2006
Messages : 344
Points : 116
Points : 116
voici le code en entier peut etre se sera mieux:

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
 
<?php
 require_once("../includes/mainfile.php");
 require_once("../includes/check_rights.php");
 include("../includes/functions.php");
 include("../includes/constants.php");
 
  $nborderpage=15;
  //echo " Number max of order :  $nborderpage";
 
  //echo "<br>";
  //echo "<br>";
 
  $sql1="SELECT count(*) pgn FROM dorders WHERE DueDate IS NOT NULL";
  //echo " $sql1 = ".$sql1;
 
  //echo "<br>";
  //echo "<br>";
 
  $result = $db->sql_query($sql1);
  //echo " $result = ".$result;
 
  //echo "<br>";
  //echo "<br>";
 
 
  $rows = $db->sql_fetchrow($result);
  //echo " $rows = ".$rows['pgn'];
  //echo "<br>";
  //echo "<br>";
 
 
  $pn = intval($rows['pgn']/$nborderpage);
  //echo " $pn = ".$pn;
  //echo "<br>";
  //echo "<br>";
 
  $start=($pn*$nborderpage);
  //echo " $start = ".$start;
  //echo "<br>";
  //echo "<br>";
 
  $end=$nborderpage;
  //echo " $end = ".$end;
  //echo "<br>";
  //echo "<br>";
 
  $limit = " limit " . ($pn * $nborderpage) . ",$nborderpage";
  //echo " $limit = ".$limit;
  //echo "<br>";
  //echo "<br>";
 
  $sql3="SELECT orderid FROM  dorders WHERE DueDate IS NOT NULL ORDER BY orderid $limit";
  //echo " $sql3 = ".$sql3; 
 
  //echo "<br>";
  //echo "<br>";
 
 /*$result = $db->sql_query($sql6);
 if ($rows = $db->sql_numrows($result)){
  $pages = intval($rows/$rpp);
  if ($page = $_GET['page']){
   if($page > $pages){
    $page = $pages;
   }
   if($page <= 1){
    $page = 1;
   }
   $limit = " limit " . ($page * $rpp) . ",$rpp";
  } else {
   $limit = " limit 0,$rpp";
  }
 }*/
 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<a href="http://www.w3.org/TR/html4/loose.dtd" target="_blank">http://www.w3.org/TR/html4/loose.dtd</a>">
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <title>Orders List</title>
 <META NAME="Title" CONTENT="Replacement DashBoards">
 <META NAME="Description" CONTENT="DashBoards for the DD section of JOLC">
 <META NAME="Keywords" CONTENT="opoce,droit d&eacute;riv&eacute;, secondary legislation,jo,jolc">
 <META NAME="Creator" CONTENT="OPOCE/DD">
 <META NAME="Language" CONTENT="en">
 <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
 <META HTTP-EQUIV="Expires" CONTENT="-1">
 <LINK REL="StyleSheet" HREF="../css/style.css" TYPE="text/css">
</head>
<body>
<?php
//echo $_GET['page'];
//echo "<br>";
//echo "<br>$pages";
//$action = array("ORDER.DOCUMENT.PROOF"=>"Order Galleys","SEND.CORRECTED.PROOF"=>"Send Corrected Proofs","DELIVERY.DOCUMENT.PROOF"=>"Galley Proofs delivered");
 $pgno = $_GET['pgno'];
 $orderby = $_GET['orderby'];
 $sql4="SELECT * FROM ((SELECT * FROM (SELECT dorders.OrderID, OrderDate, DueDate, PriorReading, Paper, dorders.Status, Name, ACTION, nodeid FROM dorders, packages WHERE dorders.OrderID = packages.orderID) as tab1)
UNION 
(SELECT * FROM (SELECT dorders.OrderID, OrderDate, DueDate, PriorReading, Paper, dorders.Status, Name, ACTION , nodeid FROM packages, inv_orders, dorders WHERE concat( inv_orders.invoicedate, '_JVE_OPE' ) = packages.name AND dorders.orderid = inv_orders.orderid) as tab2)
UNION
(SELECT * FROM (SELECT dorders.OrderID, OrderDate, DueDate, PriorReading, Paper, dorders.Status, Name, Action, nodeid FROM packages, inv_orders, invoices, dorders WHERE concat(invoices.acceptedDate, '_OPE_JVE')=packages.name AND dorders.orderid=inv_orders.orderid AND invoices.invoiceDate=inv_orders.invoicedate) as tab3)
ORDER BY orderid, name) as tabm WHERE 1 ORDER BY $orderby LIMIT " . $pgno*50 . ", 50";
 
  //echo " $sql4 = ".$sql4; 
 
  //echo "<br>";
  //echo "<br>";
$result = $db->sql_query($sql4);
if ($db->sql_numrows($result)){
 $row_class1 = 't_row_odd';
 $row_class2 = 't_row_even';
 
 $row_class = $row_class1;
 
 $previous_oID = 0;
 
echo <<< myBlock
 <table align="center" width="900" border="0" cellspacing="1" cellpadding="0">
   <tr>
  <th width="150" scope="col">Order ID <a href="orders_list.php?pgno=$pgno&orderby=OrderID"></th>
  <th width="100" scope="col"><a href="orders_list.php?pgno=$pgno&orderby=DueDate">Due Date </th>
  <th width="050" scope="col"><a href="orders_list.php?pgno=$pgno&orderby=PriorReading">P. R. </th>
  <th width="050" scope="col"><a href="orders_list.php?pgno=$pgno&orderby=Paper">Paper </th>
  <th width="050" scope="col"><a href="orders_list.php?pgno=$pgno&orderby=Status">Status </th>
  <th width="300" scope="col"><a href="orders_list.php?pgno=$pgno&orderby=Name">Package</th>
  <th width="200" scope="col"><a href="orders_list.php?pgno=$pgno&orderby=ACTION">Type</th>
 
   </tr>\n
myBlock;
  //$lastorderid = 'dummy';
 
 while($row = $db->sql_fetchrow($result)) 
 {
  $orderId = $row['OrderID'];
  //if ($lastorderid != $orderId) {
   $duedate=$row['DueDate'];
   $pr=$row['PriorReading'];
   $paper=$row['Paper'];
   $status=$row['Status'];
  //} else {
   //$duedate = $pr = $paper = $status = $orderId = '';
  //}
  //$lastorderid = $row['OrderID'];
  $package = $row['Name'];
 
  $action=$row['ACTION'];
  $nodeid = $row['nodeid'];
 
  $i++;
echo <<< myBlock
  <tr class="$row_class" onMouseover="this.className='highlight_a';" onMouseout="this.className='$row_class';">
   <td><a href="documents_list.php?OrderID=$orderId">$orderId</a></td>
   <td>$duedate</td>
   <td>$pr</td>
   <td>$paper</td>
   <td>$status</td>
   <td align="center"><a href="$ll_base?func=ll&objId=$nodeid&objAction=download">$package</a></td>
   <td>$action</td>
 
  </tr>\n
myBlock;
  flip_color();
/*  if ($i==100){
echo <<< myBlock
   <tr>
  <th width="150" scope="col">Order ID </th>
  <th width="100" scope="col">Due Date </th>
  <th width="050" scope="col">P. R. </th>
  <th width="050" scope="col">Paper </th>
  <th width="050" scope="col">Status </th>
  <th width="300" scope="col">Package</th>
  <th width="200" scope="col">Type</th>
 
   </tr>\n
myBlock;
   $i = 0;
  }*/
 }
echo <<< myBlock
 </table>\n
myBlock;
} else {
echo <<< myBlock
 <h2>No Orders in the DB.</h2>\n
myBlock;
/*echo <<< Block
  <input type="hidden" name="GetOrderID" value="$_GET['OrderID']">
 
Block;*/
}
$sql5="SELECT * FROM ((SELECT * FROM (SELECT dorders.OrderID, OrderDate, DueDate, PriorReading, Paper, dorders.Status, Name, ACTION, nodeid FROM dorders, packages WHERE dorders.OrderID = packages.orderID) as tab1)
UNION 
(SELECT * FROM (SELECT dorders.OrderID, OrderDate, DueDate, PriorReading, Paper, dorders.Status, Name, ACTION , nodeid FROM packages, inv_orders, dorders WHERE concat( inv_orders.invoicedate, '_JVE_OPE' ) = packages.name AND dorders.orderid = inv_orders.orderid) as tab2)
UNION
(SELECT * FROM (SELECT dorders.OrderID, OrderDate, DueDate, PriorReading, Paper, dorders.Status, Name, Action, nodeid FROM packages, inv_orders, invoices, dorders WHERE concat(invoices.acceptedDate, '_OPE_JVE')=packages.name AND dorders.orderid=inv_orders.orderid AND invoices.invoiceDate=inv_orders.invoicedate) as tab3)
ORDER BY orderid, name) as tabm WHERE 1";
 
$maxrow=50;
/*echo maxrow;
echo $maxrow;
echo "<br>";
echo "<br>";*/
 
$result5 = $db->sql_query($sql5);
$numrows = $db->sql_numrows($result5);
/*echo $numrows;
echo "<br>";
echo "<br>";*/
$maxpage=round($numrows/$maxrow);
/*echo maxpage;
echo $maxpage;
echo "<br>";
echo "<br>";*/
 
  echo"<div align='center' name='btn'>";
  echo"<br>";
  echo"<br>";
  echo"<input type='button' name='first' value='<<' onclick='orders_list.php?pgno=$pgno&orderby=OrderID'>";
  echo"<input type='button' name='before' value='<' onclick='orders_list.php?pgno=($pgno-1)&orderby=OrderID'>";
  echo"<input type='text' name='numpage' value='' >";
  echo"<input type='button' name='next' value='>' onclick='orders_list.php?pgno=".($pgno+1)."&orderby=OrderID'>";
  echo"<input type='button' name='last' value='>>' onclick='orders_list.php?pgno=($maxpage+1)&orderby=OrderID'>";
 
  echo"<select name='pages'>";
  for($i=1;$i<=($maxpage+1);$i++)
  {
   echo"<option value='$i' onchange='orders_list.php?pgno=(".$i.")&orderby=OrderID'>$i";
  }
  echo"</select>";
 
 
 
  echo"</div>";
 
?>
</body>
</html>
megapacman est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/05/2006, 10h12   #14
Expert Confirmé

 
Avatar de Amara
 
Inscription : juillet 2004
Messages : 2 684
Détails du profil
Informations personnelles :
Localisation : France, Sarthe (Pays de la Loire)

Informations forums :
Inscription : juillet 2004
Messages : 2 684
Points : 2 910
Points : 2 910
Regarde les URLs qui s'affichent avant et après rafraîchissement de ta page et vois si ça correspond à ce que tu veux.

(au niveau des valeurs des paramètres)
(Bis)
Amara est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/05/2006, 10h22   #15
Membre habitué
 
Inscription : janvier 2006
Messages : 344
Détails du profil
Informations forums :
Inscription : janvier 2006
Messages : 344
Points : 116
Points : 116
Salut , désolé

ok quand je rafraichi j ai une page blanche
et quand je charge la page , dans ma barre de status j ai un message errors on page le resultat de ma requete est dans mon tableau ok mais les boutons fonctionne pas
quand je clique aussi sur ma page j ai le lien qui apparait:

Code :
1
2
3
 
 
orders_list.php?pgno=0&orderby=orderid


je sais pas si je réponds à ta question merci pour ton aide
megapacman est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/05/2006, 10h27   #16
Expert Confirmé

 
Avatar de Amara
 
Inscription : juillet 2004
Messages : 2 684
Détails du profil
Informations personnelles :
Localisation : France, Sarthe (Pays de la Loire)

Informations forums :
Inscription : juillet 2004
Messages : 2 684
Points : 2 910
Points : 2 910
Donne nous l'URL complète de la page que tu appelles au départ, puis celle qui est appellée après appui sur un bouton (les URLs qui s'affichent dans la barre d'adresse de ton navigateur).
Comme ça on saura si c'est un problème de JS (apparament oui), auquel cas redirige toi vers le forum approprié
Amara est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/05/2006, 10h39   #17
Membre habitué
 
Inscription : janvier 2006
Messages : 344
Détails du profil
Informations forums :
Inscription : janvier 2006
Messages : 344
Points : 116
Points : 116
la page index:

http://oppc856/dd2_dev/index.php

j ai une frame a gauche ou est mon lien:
http://oppc856/dd2_dev/left.php


voila le lien de ma page :

http://oppc856/dd2_dev/modules/order...rderby=orderid
megapacman est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/05/2006, 10h53   #18
Membre habitué
 
Inscription : mars 2006
Messages : 186
Détails du profil
Informations personnelles :
Âge : 26
Localisation : France, Bas Rhin (Alsace)

Informations forums :
Inscription : mars 2006
Messages : 186
Points : 120
Points : 120
mais tu fou un tableau de toutes tes lignes en variable de session et chaque page de ton tableau affichera certaines lignes du tableau délimitées par des bornes.

Ca m'a l'air bien compliqué ce que tu essaye de faire, meme si j'avoue que j'ai pas eu le courage de lire
highman est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/05/2006, 10h54   #19
Expert Confirmé

 
Avatar de Amara
 
Inscription : juillet 2004
Messages : 2 684
Détails du profil
Informations personnelles :
Localisation : France, Sarthe (Pays de la Loire)

Informations forums :
Inscription : juillet 2004
Messages : 2 684
Points : 2 910
Points : 2 910
C'est moi qui doit pas être trop clair dsl.

Nouvelle reformulation : quand tu cliques sur un bouton, est-ce que les nouvelles valeurs de tes variables qui s'affichent dans ta barre d'adresse (pgno=...) sont bien celles que tu attends ?
Amara est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/05/2006, 11h19   #20
Membre habitué
 
Inscription : janvier 2006
Messages : 344
Détails du profil
Informations forums :
Inscription : janvier 2006
Messages : 344
Points : 116
Points : 116
non l adresse ne s affiche pas

rien ne se produit comme si il ne voyait pas le lien
megapacman est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 03h44.


 
 
 
 
Partenaires

Hébergement Web