Bonjour,

Je suis en train d'essayer de rajouter un if dans la requête ci-dessous qui fonctionne bien :


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
	$updates_raw = 	"select * from " 
			. TABLE_PRODUCTS_DESCRIPTION . " pd, " 
			. TABLE_PRODUCTS 
			. " p LEFT JOIN " 
			. TABLE_MANUFACTURERS . " m "
			. "ON "
			. "( p.manufacturers_id = m.manufacturers_id ) "
			. " LEFT JOIN "
			. TABLE_PRODUCTS_TO_CATEGORIES . " ptc "
			. " ON "
			. "( p.products_id 	= ptc.products_id ) "
			. " LEFT JOIN "
			. TABLE_CATEGORIES_DESCRIPTION . " cd "
			. " ON "
			. "( ptc.categories_id 	= cd.categories_id ) "
			. "where "
			. "p.products_id = pd.products_id "
			. "and "
			. "pd.language_id = $languages_id "
			. "and "
			. "cd.language_id = $languages_id "
			. "and "
			. "( pd.products_name like '%" . $keywords . "%' "
			. "or "
			. "p.products_model like '%" . $keywords . "%' "
			. "or "
			. "cd.categories_name like '%" . $keywords . "%' "
			. "or "
			. "m.manufacturers_name like '%" . $keywords . "%' ) "
			. "and "
			. " cd.categories_id = " . $categories
			. " order by "
			. "$order "
 
	; // END updates_raw

Voila requête lorsque j'ai rajouté mon if (en bas de la requete)

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
	$updates_raw = 	"select * from " 
			. TABLE_PRODUCTS_DESCRIPTION . " pd, " 
			. TABLE_PRODUCTS 
			. " p LEFT JOIN " 
			. TABLE_MANUFACTURERS . " m "
			. "ON "
			. "( p.manufacturers_id = m.manufacturers_id ) "
 
			//Fab
			. " LEFT JOIN "
			. TABLE_PRODUCTS_TO_CATEGORIES . " ptc "
			. " ON "
			. "( p.products_id 	= ptc.products_id ) "
			. " LEFT JOIN "
			. TABLE_CATEGORIES_DESCRIPTION . " cd "
			. " ON "
			. "( ptc.categories_id 	= cd.categories_id ) "
			. "where "
			. "p.products_id = pd.products_id "
			. "and "
			. "pd.language_id = $languages_id "
			. "and "
			. "cd.language_id = $languages_id "
			. "and "
			. "( pd.products_name like '%" . $keywords . "%' "
			. "or "
			. "p.products_model like '%" . $keywords . "%' "
			. "or "
			. "cd.categories_name like '%" . $keywords . "%' "
			. "or "
			. "m.manufacturers_name like '%" . $keywords . "%' ) "
			. if ($categories == 0) {
			. "and "
			. " cd.categories_id = " . $categories
			}
			. " order by "
			. "$order "
 
	; // END updates_raw

Qu'est ce qui ne vas pas dans la syntax suivante? :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
			. if ($categories == 0) {
			. "and "
			. " cd.categories_id = " . $categories
			}
Voici l'erreur :

arse error: syntax error, unexpected T_IF in



Merci de votre aide à tous.