Salut à tous,
J'ai quelques problèmes à mettre en place ma boucle php.
J'ai une fonction que je découpe en 2 parties afin de séparer les variables et pouvoir les faires apparaitres dans 2 div différentes.
Bon c'est pas super clair, voici le code:
Fonction 1:
J'obtiens: catégorie 1 - catégorie 2 - catégorie 3 - catégorie 4
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 function get_cats() { global $settings, $prefix, $root_path; $cat_data = ""; $res = mysql_query("select * from {$prefix}category WHERE cat_parent_id=0 ORDER BY cat_name") or report(); if(mysql_num_rows($res)==0) echo "Aucune donnée"; else { $tot = mysql_num_rows($res); $spannum = $tot+2; for($i=0;$i<'4;$i++) { $row = mysql_fetch_assoc($res); $cat_url = $settings['set_seo_onoff'] =='off' ? "$root_path/".plaintext($row['cat_name'])."-$row[cat_id].html" : "$root_path/category.php?id=$row[cat_id]"; $cat_data .= "<a href=$cat_url>$row[cat_name]</a>"; } } return $cat_data; }
Fonction 2:
J'obtiens: catégorie 1 - catégorie 2 - catégorie 3 - catégorie 4
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 function get_cats2() { global $settings, $prefix, $root_path; $cat_data = ""; $res = mysql_query("select * from {$prefix}category WHERE cat_parent_id=0 ORDER BY cat_name") or report(); if(mysql_num_rows($res)==0) echo "Aucune donnée"; else { $tot = mysql_num_rows($res); $spannum = $tot+2; for($i=5;$i<$tot;$i++) { $row = mysql_fetch_assoc($res); $cat_url = $settings['set_seo_onoff'] =='off' ? "$root_path/".plaintext($row['cat_name'])."-$row[cat_id].html" : "$root_path/category.php?id=$row[cat_id]"; $cat_data .= "<a href=$cat_url>$row[cat_name]</a>"; } } return $cat_data; }
au lieu de
catégorie 5 - catégorie 6 - catégorie 7 - catégorie 8
Comment est ce que je dois m'y prendre?
Merci,
Partager