Salut,
Je poste ici mon probleme en espérant que je sois au bon endroit.
J'ai une page php avec une recherche multicritère avec notamment une recherche sur une plage de date. Je dois ajouter par la suite d'autre critère en plus comme un nom de client via une combobox.
Lorsque ma page se charge pas de souci, le css est appliqué sans probleme sur la premiere page. (2018-05-14_153254_affichage_page1_ok.jpg)
Par contre, lorsque je clique sur la page 2 là, je perds toute ma mise en forme, mes champs de texte, mes combobox, ect.. Bref le css ne s'applique pas. (2018-05-14_153358_passage_page2.jpg)
Je vous mets en dessous le code de mon projet:
index.php:
fetch_data.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php header('Content-type: text/html; charset=iso-8859-1'); include 'db_connect.php'; //remplissage de la comboclient $qry_clt="select id,name from products where isactive = '1'"; $data = $conn->prepare($qry_clt); $data->execute(); //remplissage Severite $qry_sev="select id, value from bug_severity"; $sev_data = $conn->prepare($qry_sev); $sev_data->execute(); $conn=null; ?> <!DOCTYPE HTML> <html> <head> <title>Tickets - Demo</title> <link rel="stylesheet" type="text/css" href="css/style.css" /> <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" /> <script type = "text/javascript" src="js/bootstrap.min.js"></script> <script type = "text/javascript" src="js/jquery-3.3.1.js"></script> <script type = "text/javascript" src="js/jquery-1.7.1.min.js"></script> <script type = "text/javascript" src="js/jquery-ui.js"></script> <link rel="stylesheet" type="text/css" href="css/jquery-ui.min.css" /> <script> $(document).ready(function(){ $.datepicker.setDefaults({ dateFormat: 'yy-mm-dd', changeYear:true, changeMonth:true }); $(function(){ $("#from_date").datepicker(); $("#to_date").datepicker(); }); $('#filterbutton').click(function(){ var from_date = $('#from_date').val(); var to_date = $('#to_date').val(); if(from_date != '' && to_date != '') { $.ajax({ url:"fetch_data.php", method:"POST", data:{from_date:from_date, to_date:to_date}, success:function(data) { $('#table_data').html(data); } }); } else { alert("Please Select Date"); } }); }); </script> </head> <body> <h1>LISTE DES TICKETS-TEST<br></h1> <label>Du:</label><input id="from_date" type="text" class="datepicker" name="from_date" value= ""> <label>Au:</label><input id="to_date" type="text" class="datepicker" name="to_date" value=""> <!-- Combo client --> <select id="cbclient" name="cbclient"> <option value = "" disabled selected>---Select---</option> <?php while($row=$data->fetch(PDO::FETCH_ASSOC)){ echo "<option value=".$row['id'].">".$row['name']."</option>"; } ?> </select> <!-- severite --> <select id="cbseverite" name="cbseverite"> <option value = "" disabled selected>---Select---</option> <?php while($row=$sev_data->fetch(PDO::FETCH_ASSOC)){ echo "<option value=".$row['id'].">".$row['value']."</option>"; } ?> </select> <input id="filterbutton" type="submit" value="Filtrer" name="filterbutton"> <div id='retrieved-data' style='height:15em;'> <!-- affichage des datas. --> <img src="images/ajax-loader.gif" /> </div> <script type = "text/javascript"> $(function(){ // affiche la premiere page getdata(1); }); //fonction getdata(pageno){ function getdata(pageno){ // source de données var targetURL = 'fetch_data.php?page=' + pageno; $('#retrieved-data').html('<img src="images/ajax-loader.gif" />'); // load to show new data $('#retrieved-data').load(targetURL).hide().fadeIn('slow'); } </script> </body> </html>
Si besoin du code gérant la pagination pas de soucis.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php header('Content-type: text/html; charset=iso-8859-1'); //fetch.php //include include 'db_connect.php'; include 'pagination.php'; $startdate=""; $enddate=""; $urlparam=""; //********************** DEBUT SQL BUILD QUERY *********************************************** $sql = "SELECT `bugs_activity`.`bug_id` AS `bug_id`, `products`.`name` AS `client`, `bugs`.`cf_platforme` AS `plateforme`, `bugs_activity`.`bug_when` AS `bug_when`, `bugs`.`product_id` AS `product_id`, `bug_severity`.`id` AS `severity_id`, `bugs`.`bug_severity` AS `severité`, COUNT(*) AS count FROM `bugs_activity`, `bug_severity`, `bugs`, `products` WHERE `bugs`.`product_id` = `products`.`id` AND `bug_severity`.`value` = `bugs`.`bug_severity` AND `bugs`.`bug_id` = `bugs_activity`.`bug_id` AND `bugs_activity`.`bug_when` IS NOT NULL AND `bugs_activity`.`added` = 'REOPENED'"; //debut gestion des dates if(!empty($_GET['from_date'])){ $startdate= $_GET['from_date']; } if(!empty($_GET['to_date'])){ $enddate=$_GET['to_date']; } // si la date est vide on met par défaut // date debut: date jour -7 // date fin: date jour +7 //gestion si les dates sont vides if(empty($_GET['from_date'])){ $startdate=date('Y-m-d', strtotime("-7 days")); } if(empty($_GET['to_date'])){ $enddate=date('Y-m-d', strtotime("+7 days")); } $sql .=" AND `bugs_activity`.`bug_when` BETWEEN '$startdate' and '$enddate'"; //client if(!empty($_GET['client'])){ $sql .= "AND `products`.`name` = '$client'"; } //severité if(!empty($_GET['severité'])){ $sql .= "AND `bug_severity`.`value` = '$severite'"; } //fin de requete $sql .=" GROUP BY `bugs_activity`.`bug_id`"; $sql .=" ORDER BY `bugs_activity`.`bug_id`, `bugs_activity`.`bug_when` ASC"; //********************** FIN SQL BUILD QUERY *********************************************** //*********************** CONSTRUCTION DE LA PAGE ****************************************** $urlparam="from_date={$startdate}&to_date={$enddate}"; $pager = new PS_Pagination($conn, $sql, 10, 5, $urlparam); $pager->setDebug(true); $rs = $pager->paginate(); //calcul du nb de lignes que retourne la requete $num = $rs->rowCount(); if($num >= 1 ){ echo "<div id=table_data>"; echo "<table id=table_data class=data-table>"; echo "<thead>"; echo "<tr>"; echo "<th>BUG_ID</th>"; echo "<th>PRODUCT_ID</th>"; echo "<th>CLIENT</th>"; echo "<th>PLATEFORME</th>"; echo "<th>SEVERITY_ID</th>"; echo "<th>SEVERITE</th>"; echo "<th>DATE</th>"; echo "<th>NB_REOPENED</th>"; echo "</tr>"; echo "</thead>"; echo "<tbody>"; while ($row = $rs->fetch(PDO::FETCH_ASSOC)){ echo "<tr class='data-tr' align='center'>"; echo "<td><a href=https://support.datalog-finance.com/show_bug.cgi?id={$row["bug_id"]}> {$row["bug_id"]}</a></td>"; echo "<td>{$row["product_id"]}</td>"; echo "<td>{$row["client"]}</td>"; echo "<td>{$row["plateforme"]}</td>"; echo "<td>{$row["severity_id"]}</td>"; echo "<td>{$row["severité"]}</td>"; echo "<td>{$row["bug_when"]}</td>"; echo "<td>{$row["count"]}</td>"; echo "</tr>"; } echo "</tbody>"; echo "</table>"; echo "</div>"; }else{ // si pas de données echo "Pas de données disponible!"; } echo "<div class='page-nav'>"; // Affiche n° de page echo $pager->renderFullNav(); echo "</div>"; //fermeture de la connexion à mysql $conn=null; ?>
Merci pour votre aide,
Partager