Bonjour,
J'ai deux liste liees, une pour les categories et une autres pour les sous-categories, quand je choisis une categorie et apres une sous-categorie le code et l'affichage sont bien, mais, en meme temps et sans rafraichir la page je change de categorie et je choisis une sous-categorie, l'affichage de cette derniere est place a la meme page que la premiere selection de la premiere categorie, un éclaircissement :
1er choix:
+ categorie1
- sous categorie1
-- Affichage des resultat du 1er choix
2eme choix:
+ categorie2
- sous categorie2
-- Affichage des resultat du 2eme choix
-- Affichage des resultat du 1er choix (c'est la le probleme)
ci-joint mes codes:
index.php:
main.js:
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 <form> <form> <select name="users" onchange="showUser(this.value)"> <option value="0" disabled="disabled" selected="selected">- Select Make</option> <option value="1">الشيوخ</option> <option value="2">البلدان</option> <option value="3">الروايات</option> <option value="4">التلاوات</option> </select> <span id="txtHint"></span> <!-- Affichage de la 2eme liste --> <span id="txtHint2"></span> <!-- Affichage du resultat de la fonction showUser2 --> <span id="txtHint3"></span> <!-- Affichage du resultat de la fonction showUser3 --> <span id="txtHint4"></span> <!-- Affichage du resultat de la fonction showUser4 --> </form>
test.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 function showUser(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","Sawtiyat/Quoran/test.php?id="+str,true); xmlhttp.send(); } function showUser2(str) { if (str=="") { document.getElementById("txtHint2").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint2").innerHTML=xmlhttp.responseText; } } str=encodeURI(str); xmlhttp.open("GET","Sawtiyat/Quoran/sheikh_selected.php?sheikh_ar="+str,true); xmlhttp.send(); } function showUser3(str) { if (str=="") { document.getElementById("txtHint3").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint3").innerHTML=xmlhttp.responseText; } } str=encodeURI(str); xmlhttp.open("GET","Sawtiyat/Quoran/riwaya_selected.php?riwaya="+str,true); xmlhttp.send(); } function showUser4(str) { if (str=="") { document.getElementById("txtHint4").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint4").innerHTML=xmlhttp.responseText; } } str=encodeURI(str); xmlhttp.open("GET","Sawtiyat/Quoran/nationality_selected.php?nationality="+str,true); xmlhttp.send(); }
sheikh_ar.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 <?php //print_r($_GET); $id = $_GET['id']; echo 'id'.$id.'<br>'; if ($id == '1') { //$theorder = 'sheikh_ar'; include 'sheikh_ar.php'; } if ($id == '2') { //$theorder = 'riwaya'; include 'nationality.php'; } if ($id == '3') { //$theorder = ''; include 'riwaya.php'; } if ($id == '4') { //$theorder = ''; include 'tilawa.php'; } ?>
sheikh_selected.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 <?php print_r($_GET); include '../../Included_Files/Connect.php'; // selection DB sawtiyat mysql_select_db($db_sawtiyat) or die ('Erreur de selection de la BD sawtiyat: '.mysql_error()); // selectionner tous les shiekhs $select_qr = 'SELECT DISTINCT sheikh_ar FROM sheikh_tbl WHERE quoran=1'; echo '<font color="red">'.$select_qr.'</font><br>'; $query_qr = mysql_query($select_qr) OR DIE (mysql_error()); $nb = mysql_num_rows($query_qr); //echo 'total: <font color="green">'.$nb.'</font><br>'; echo ' <select name="users2" onchange="showUser2(this.value)"> <option value="-1" disabled="disabled" selected="selected">- Select Make</option> <option value="0">جميع المقرئين</option> '; while ($row_qr = mysql_fetch_array($query_qr)) { // on extract les donnees extract($row_qr); echo '<option value="'.$sheikh_ar.'">'.$sheikh_ar.'</option>'; echo $sheikh_en.' '.$sheikh_ar; echo $riwaya.' '; echo $nationality.' '; } echo '</select>'; //echo '</form>'; ?>
nationality.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 <?php print_r($_GET); include '../../Included_Files/Connect.php'; include '../../Included_Files/Functions.php'; // selection DB sawtiyat mysql_select_db($db_sawtiyat) or die ('Erreur de selection de la BD sawtiyat: '.mysql_error()); $select_qr2 = 'SELECT * FROM sheikh_tbl WHERE quoran=1 AND sheikh_ar = "'.$sheikh_ar.'"'; //echo '<font color="red">'.$select_qr2.'</font><br>'; $query_qr2 = mysql_query($select_qr2) OR DIE (mysql_error()); $nb2 = mysql_num_rows($query_qr2); //echo 'total: <font color="green">'.$nb2.'</font><br>'; echo '<table width="700" align="center" cellpadding="5">'; echo '<tr align="center" bgcolor="#42afdc"><td colspan="4">'; echo 'عدد النتائج: '.$nb2; //echo ' '; //echo '[ <a href="Idara/generer.php?menu=Demandq" rel="gb_page[800, 400] title="أنقر هنا لطلب مقرئ جديد ">طلب قارئ جديد </a>]'; //echo ' '; //echo '[ طلبات تحت الإنتظار ' .$nbq.' ]'; echo '</td>'; while ($row_qr2 = mysql_fetch_array($query_qr2)) { // on extract les donnees extract($row_qr2); if ($i%4 == 0) echo '<tr align="center">'; $i++; $filename = '../../'.$path2sheikh.$sheikh_en.'.png'; $print_filename = $path2sheikh.$sheikh_en.'.png'; //echo $filename.'<br>'; echo '<td width="160"><a href="Sawtiyat-Quoran-'.$sheikh_en.'-id_shk'.$id_shk.'.html" class="Link01">'; if (file_exists($filename)) { $pic = '<img src="'.$print_filename.'" width="120" height="120" class="shadow" />'; } else { $pic = '<img src="'.$path2sheikh.'Unknown.png" width="120" height="120" class="shadow" />'; } echo $pic; $numbers = array (1,2,3,4); $tilawat = array ('مرتل', 'مجود'); $riwayat = array ('حفص عن عاصم', 'ورش عن نافع', 'حمزة عن خلف', 'السوسي عن أبي عمرو'); $riwaya = str_replace ($numbers, $riwayat, $riwaya); $tilawa = str_replace ($numbers, $tilawat, $tilawa); echo '</a>'; echo '<br>'; echo '<b>'.$sheikh_ar.'</b><br>'; echo '<b>'.$tilawa.'</b><br>'; echo '<b>'.$riwaya.'</b><br>'; // selection DB sawtiyat //mysql_select_db($db_sawtiyat) or die ('Erreur de selection de la BD sawtiyat: '.mysql_error()); $select_s = 'SELECT COUNT(*) FROM sheikh_reciting WHERE id_shk2 = "'.$id_shk.'"'; //echo $select_s; $result_s = mysql_query($select_s) OR DIE ('Unable to select recitings'. mysql_error()); $data_s = mysql_fetch_array($result_s); //echo $data_s[0]; echo 'عدد السور: '; if ($data_s[0] == '114') { $data_s[0] = '<img src="'.$path2icons.'mushaf.gif" width="20" height="20" alt="المصحف كاملا" title="المصحف كاملا" />'; } else { $data_s[0] = $data_s[0]; } echo $data_s[0]; //echo '<br>'; //echo 'رواية: '.$riwaya; //echo '<br>'; //include 'Files/Votes/votes_result.php'; echo '</td>'; if ($i%4 ==0)echo "</tr>"; } echo '</table>'; ?>
nationality_selected.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 <font color="gray">nationality</font><br /> <?php print_r($_GET); include '../../Included_Files/Connect.php'; // selection DB sawtiyat mysql_select_db($db_sawtiyat) or die ('Erreur de selection de la BD sawtiyat: '.mysql_error()); // selectionner tous les shiekhs $select_qr = 'SELECT DISTINCT nationality FROM sheikh_tbl WHERE quoran=1'; echo '<font color="red">'.$select_qr.'</font><br>'; $query_qr = mysql_query($select_qr) OR DIE (mysql_error()); $nb = mysql_num_rows($query_qr); //echo 'total: <font color="green">'.$nb.'</font><br>'; echo ' <select name="users2" onchange="showUser4(this.value)"> <option value="-1" disabled="disabled" selected="selected">- Select Make</option> <option value="0">جميع البلدان</option> '; while ($row_qr = mysql_fetch_array($query_qr)) { // on extract les donnees extract($row_qr); echo '<option value="'.$nationality.'">'.$nationality.'</option>'; echo $sheikh_en.' '.$sheikh_ar; echo $riwaya.' '; echo $nationality.' '; } echo '</select>'; ?>
riwaya.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 <font color="gray">nationality selected</font><br /> <?php print_r($_GET); include '../../Included_Files/Connect.php'; include '../../Included_Files/Functions.php'; $nationality = $_GET['nationality']; echo 'testbis nationality'.$nationality.'<br>'; // selection DB sawtiyat mysql_select_db($db_sawtiyat) or die ('Erreur de selection de la BD sawtiyat: '.mysql_error()); $select_qr2 = 'SELECT * FROM sheikh_tbl WHERE quoran=1 AND nationality = "'.$nationality.'"'; echo '<font color="red">'.$select_qr2.'</font><br>'; $query_qr2 = mysql_query($select_qr2) OR DIE (mysql_error()); $nb2 = mysql_num_rows($query_qr2); //echo 'total: <font color="green">'.$nb2.'</font><br>'; echo '<table width="700" align="center" cellpadding="5">'; echo '<tr align="center" bgcolor="#42afdc"><td colspan="4">'; echo 'عدد النتائج: '.$nb2; //echo ' '; //echo '[ <a href="Idara/generer.php?menu=Demandq" rel="gb_page[800, 400] title="أنقر هنا لطلب مقرئ جديد ">طلب قارئ جديد </a>]'; //echo ' '; //echo '[ طلبات تحت الإنتظار ' .$nbq.' ]'; echo '</td>'; while ($row_qr2 = mysql_fetch_array($query_qr2)) { // on extract les donnees extract($row_qr2); if ($i%4 == 0) echo '<tr align="center">'; $i++; $filename = '../../'.$path2sheikh.$sheikh_en.'.png'; $print_filename = $path2sheikh.$sheikh_en.'.png'; //echo $filename.'<br>'; echo '<td width="160"><a href="Sawtiyat-Quoran-'.$sheikh_en.'-id_shk'.$id_shk.'.html" class="Link01">'; if (file_exists($filename)) { $pic = '<img src="'.$print_filename.'" width="120" height="120" class="shadow" />'; } else { $pic = '<img src="'.$path2sheikh.'Unknown.png" width="120" height="120" class="shadow" />'; } echo $pic; $numbers = array (1,2,3,4); $tilawat = array ('مرتل', 'مجود'); $riwayat = array ('حفص عن عاصم', 'ورش عن نافع', 'حمزة عن خلف', 'السوسي عن أبي عمرو'); $riwaya = str_replace ($numbers, $riwayat, $riwaya); $tilawa = str_replace ($numbers, $tilawat, $tilawa); echo '</a>'; echo '<br>'; echo '<b>'.$sheikh_ar.'</b><br>'; echo '<b>'.$tilawa.'</b><br>'; echo '<b>'.$riwaya.'</b><br>'; echo 'عدد السور: '; if ($data_s[0] == '114') { $data_s[0] = '<img src="'.$path2icons.'mushaf.gif" width="20" height="20" alt="المصحف كاملا" title="المصحف كاملا" />'; } else { $data_s[0] = $data_s[0]; } echo $data_s[0]; //echo '<br>'; //echo 'رواية: '.$riwaya; //echo '<br>'; //include 'Files/Votes/votes_result.php'; echo '</td>'; if ($i%4 ==0)echo "</tr>"; } echo '</table>'; ?>
riwaya_selected.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 <font color="gray">riwaya</font><br /> <?php print_r($_GET); include '../../Included_Files/Connect.php'; $riwaya = $_GET['riwaya']; echo 'testbis riwaya'.$riwaya.'<br>'; // selection DB sawtiyat mysql_select_db($db_sawtiyat) or die ('Erreur de selection de la BD sawtiyat: '.mysql_error()); // selectionner tous les shiekhs $select_qr = 'SELECT DISTINCT riwaya FROM sheikh_tbl WHERE quoran=1'; echo '<font color="red">'.$select_qr.'</font><br>'; $query_qr = mysql_query($select_qr) OR DIE (mysql_error()); $nb = mysql_num_rows($query_qr); //echo 'total: <font color="green">'.$nb.'</font><br>'; echo ' <select name="users2" onchange="showUser3(this.value)"> <option value="-1" disabled="disabled" selected="selected">- Select Make</option> <option value="0">جميع الروايات</option> '; while ($row_qr = mysql_fetch_array($query_qr)) { // on extract les donnees extract($row_qr); $numbers = array (1,2,3,4); $tilawat = array ('مرتل', 'مجود'); $riwayat = array ('حفص عن عاصم', 'ورش عن نافع', 'حمزة عن خلف', 'السوسي عن أبي عمرو'); $riwaya2 = str_replace ($numbers, $riwayat, $riwaya); $tilawa = str_replace ($numbers, $tilawat, $tilawa); echo '<option value="'.$riwaya.'">'.$riwaya2.'</option>'; echo $sheikh_en.' '.$sheikh_ar; echo $riwaya.' '; echo $nationality.' '; } echo '</select>'; ?>
Merci d'avance
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 <font color="gray">riwaya selected</font><br /> <?php print_r($_GET); include '../../Included_Files/Connect.php'; include '../../Included_Files/Functions.php'; $riwaya = $_GET['riwaya']; echo 'testbis riwaya'.$riwaya.'<br>'; // selection DB sawtiyat mysql_select_db($db_sawtiyat) or die ('Erreur de selection de la BD sawtiyat: '.mysql_error()); $select_qr2 = 'SELECT * FROM sheikh_tbl WHERE quoran=1 AND riwaya = "'.$riwaya.'"'; echo '<font color="red">'.$select_qr2.'</font><br>'; $query_qr2 = mysql_query($select_qr2) OR DIE (mysql_error()); $nb2 = mysql_num_rows($query_qr2); //echo 'total: <font color="green">'.$nb2.'</font><br>'; echo '<table width="700" align="center" cellpadding="5">'; echo '<tr align="center" bgcolor="#42afdc"><td colspan="4">'; echo 'عدد النتائج: '.$nb2; //echo ' '; //echo '[ <a href="Idara/generer.php?menu=Demandq" rel="gb_page[800, 400] title="أنقر هنا لطلب مقرئ جديد ">طلب قارئ جديد </a>]'; //echo ' '; //echo '[ طلبات تحت الإنتظار ' .$nbq.' ]'; echo '</td>'; while ($row_qr2 = mysql_fetch_array($query_qr2)) { // on extract les donnees extract($row_qr2); if ($i%4 == 0) echo '<tr align="center">'; $i++; //echo '<br><br><br>'; //echo $sheikh_en.' '.$sheikh_ar; //echo $riwaya.' '; //echo $nationality.' '; $filename = '../../'.$path2sheikh.$sheikh_en.'.png'; $print_filename = $path2sheikh.$sheikh_en.'.png'; //echo $filename.'<br>'; echo '<td width="160"><a href="Sawtiyat-Quoran-'.$sheikh_en.'-id_shk'.$id_shk.'.html" class="Link01">'; if (file_exists($filename)) { $pic = '<img src="'.$print_filename.'" width="120" height="120" class="shadow" />'; } else { $pic = '<img src="'.$path2sheikh.'Unknown.png" width="120" height="120" class="shadow" />'; } echo $pic; $numbers = array (1,2,3,4); $tilawat = array ('مرتل', 'مجود'); $riwayat = array ('حفص عن عاصم', 'ورش عن نافع', 'حمزة عن خلف', 'السوسي عن أبي عمرو'); $riwaya = str_replace ($numbers, $riwayat, $riwaya); $tilawa = str_replace ($numbers, $tilawat, $tilawa); echo '</a>'; echo '<br>'; echo '<b>'.$sheikh_ar.'</b><br>'; echo '<b>'.$tilawa.'</b><br>'; echo '<b>'.$riwaya.'</b><br>'; // selection DB sawtiyat //mysql_select_db($db_sawtiyat) or die ('Erreur de selection de la BD sawtiyat: '.mysql_error()); $select_s = 'SELECT COUNT(*) FROM sheikh_reciting WHERE id_shk2 = "'.$id_shk.'"'; //echo $select_s; $result_s = mysql_query($select_s) OR DIE ('Unable to select recitings'. mysql_error()); $data_s = mysql_fetch_array($result_s); //echo $data_s[0]; echo 'عدد السور: '; if ($data_s[0] == '114') { $data_s[0] = '<img src="'.$path2icons.'mushaf.gif" width="20" height="20" alt="المصحف كاملا" title="المصحف كاملا" />'; } else { $data_s[0] = $data_s[0]; } echo $data_s[0]; //echo '<br>'; //echo 'رواية: '.$riwaya; //echo '<br>'; //include 'Files/Votes/votes_result.php'; echo '</td>'; if ($i%4 ==0)echo "</tr>"; } echo '</table>'; ?>
Partager