Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD > PHP & MySQL
PHP & MySQL Forum d'entraide sur les fonctions MySQL avec PHP. Avant de poster -> FAQ MySQL, Cours MySQL et Sources MySQL. Pour les questions concernant le moteur MySQL plutôt que les fonctions PHP, merci d'utiliser le forum MySQL.
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 02/01/2012, 22h31   #1
Débutant
 
Inscription : mai 2005
Messages : 1 957
Détails du profil
Informations personnelles :
Localisation : Suisse

Informations forums :
Inscription : mai 2005
Messages : 1 957
Points : 615
Points : 615
Par défaut Comment rechercher sans critère

Bonjour,
J'ai vraiment uen question simple.

J'ai ceci

Code :
1
2
3
4
 
...
$where[]						= "cp.`id_category` = 1";
...
Il va rechercher tous les produits ayant la valeur 1.
J'aimerais en fait qu'il prenne toutes les valeurs.

J'ai essayer de remplacer le 1 par le % mais sans résultat.

Avez-vous une sugestion?

Merci
__________________
Il ne suffit pas de tout savoir. Vouloir et persévérer, c'est déjà presque tout!
pierrot10 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/01/2012, 23h25   #2
Membre Expert
 
Avatar de Doksuri
 
Tiger Scott
Développeur Web
Inscription : juin 2006
Messages : 1 249
Détails du profil
Informations personnelles :
Nom : Tiger Scott
Âge : 42

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : juin 2006
Messages : 1 249
Points : 1 510
Points : 1 510
ca me fait penser a un sketch de gerome commander
"c'est comme si tu rentrais dans une boulangerie et que tu disais :
- bonjour, je voudrais.
- vous pouvez developper ?
- non, donne moi ce que tu veux mais t'as interet a tomber juste"

en gros, on peut avoir un peut plus de code, de details, de messages d'erreurs, etc...
__________________
La forme des pyramides prouve que l'Homme a toujours tendance a en faire de moins en moins.

N'oubliez pas le Le tag resolu.

Need_!
Doksuri est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2012, 02h42   #3
Débutant
 
Inscription : mai 2005
Messages : 1 957
Détails du profil
Informations personnelles :
Localisation : Suisse

Informations forums :
Inscription : mai 2005
Messages : 1 957
Points : 615
Points : 615
Ben je vais essayé dêtre plus précis

Voici un bout de code

Le premier va résupéré la valeur de ma variable
$_GET['id_category']
Code :
1
2
 
$category							= $catSearch ? $catSearch->id_category_default : Tools::getValue('id_category', 0);
Le second va faire la requete my msql
Code :
1
2
 
$query								= "SELECT count(*) as total FROM `"._DB_PREFIX_."product` p ".($category ? "LEFT JOIN `"._DB_PREFIX_."category_product` c ON (c.`id_product` = p.`id_product`)" : "")." WHERE p.`active` = 1 ".($category ? " AND c.`id_category` = ".(int)($category) : "");
Le problème c'est qu'il va traiter que le valeru int.
Je pex faire
$_GET['id_category'] = 1;
$_GET['id_category'] = 2;
$_GET['id_category'] = 3;

ca ca marche.
Mais j'aimerais qu'il extrait tous les champs quelque soit la valeut de
$_GET['id_category'];

Alors j'ai essayé plein de truc comme avec le %
$_GET['id_category'] = %

Il faudrait que $category prenne une valeur qui va faire une peu comme "ne teins pas en compte des valeur"....
__________________
Il ne suffit pas de tout savoir. Vouloir et persévérer, c'est déjà presque tout!
pierrot10 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2012, 08h06   #4
Membre expérimenté
 
Avatar de redoran
 
Homme
Developpeur- Amateur
Inscription : juin 2010
Messages : 981
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 40
Localisation : Algérie

Informations professionnelles :
Activité : Developpeur- Amateur
Secteur : Santé

Informations forums :
Inscription : juin 2010
Messages : 981
Points : 572
Points : 572
Envoyer un message via Skype™ à redoran
RE ; si j'ai bien compris tu veux faire ressortir tous les produits .
alors faut faire simple:
Select champ1 , champ2,....from tatable
redoran est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2012, 09h23   #5
Modérateur
 
Avatar de CinePhil
 
Homme Philippe Leménager
Ingénieur d'études en informatique
Inscription : août 2006
Messages : 11 029
Détails du profil
Informations personnelles :
Nom : Homme Philippe Leménager
Âge : 48
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Ingénieur d'études en informatique
Secteur : Enseignement

Informations forums :
Inscription : août 2006
Messages : 11 029
Points : 18 331
Points : 18 331
Envoyer un message via MSN à CinePhil
Il suffit de supprimer la catégorie du WHERE.
D'autant plus qu'avec ta condition de restriction sur la table de droite d'une jointure externe à gauche, tu transformes cette jointure externe en jointure interne !
__________________
Philippe Leménager. Ingénieur d'étude à l'École Nationale de Formation Agronomique.
Mon blog sur la conception des BDD, le langage SQL, le PHP avec Zend Framework...
« Ce que l'on conçoit bien s'énonce clairement, et les mots pour le dire arrivent aisément ». (Nicolas Boileau)
À la maison comme au bureau, j'utilise Mandriva Linux ou Mageïa ! Soutenons l'industrie logicielle française !
Linuxiens, comptez-vous !
CinePhil est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2012, 11h10   #6
Débutant
 
Inscription : mai 2005
Messages : 1 957
Détails du profil
Informations personnelles :
Localisation : Suisse

Informations forums :
Inscription : mai 2005
Messages : 1 957
Points : 615
Points : 615
Merci pour vos réponse, je vais regardé ceci cet après-midi
__________________
Il ne suffit pas de tout savoir. Vouloir et persévérer, c'est déjà presque tout!
pierrot10 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2012, 14h30   #7
Débutant
 
Inscription : mai 2005
Messages : 1 957
Détails du profil
Informations personnelles :
Localisation : Suisse

Informations forums :
Inscription : mai 2005
Messages : 1 957
Points : 615
Points : 615
Bonjour à tous, ben j'ai essayé vos propositions et rien ne fonctionne. Je dois eut etre me trompé. Le problème c'est que je n'ai pas trop de champs d'action cra c'est un code que j'essaye de modifier.

Voici le code en entier
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
 
<?php
@ini_set('display_errors', 'on');
 
class LiveFilter extends Module
{
 
	public $settings 						= array();
 
	public $tags							= array();
 
	public $features						= array();
 
	public $attributes						= array();
 
	public $manufacturers					= array();
 
	public $price							= array("low" => 0, "high" => 0);
 
	public function __construct()
	{
 
		$this->name 						= 'livefilter';
 
		$this->version 						= '3.0';
 
		$this->tab 							= 'search_filter';
 
		parent::__construct();
 
		$this->page 						= basename(__FILE__, '.php');
 
		$this->displayName 					= 'Live Filter PRO';
 
		$this->description 					= 'Live Filter PRO product filtering module by Endpulse';
 
		$this->settings 					= unserialize(Configuration::get('LFP_SETTINGS'));
 
		$this->settings['baseUrl'] 			= "http://".htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8');
 
		$this->settings['url'] 				= $this->settings['baseUrl']._MODULE_DIR_.'livefilter/';
 
		$this->settings['baseUrl'] 			= $this->settings['baseUrl'].__PS_BASE_URI__;
 
	}
 
	public function install() {
 
		if (!parent::install() OR		
			!$this->registerHook('leftColumn') OR
			!$this->registerHook('header'))
 
			return (false);
 
		$this->setDefaults();
 
		if (!$this->saveSettings()) return false;
 
		return true;
 
	}
 
	public function hookLeftColumn($params) {
 
		global $smarty, $cookie;
 
		//$_GET['id_category'] = 1;
 
 
 
 
		if ((Tools::getValue('id_category') != "" && isset($this->settings['lfpShowOn']['category'])) ||
			(Tools::getValue('id_product') != "" && isset($this->settings['lfpShowOn']['product'])) ||
			(isset($this->settings['lfpShowOn']['other']) && Tools::getValue('id_category') == "" && Tools::getValue('id_product') == "")) {
 
		$compat								= _PS_VERSION_ < '1.4.0' ? 1 : 0;
 
		$catSearch							= "";
 
		$language							= $cookie->id_lang ? $cookie->id_lang : Configuration::get('PS_LANG_DEFAULT');
 
		$currency							= Currency::getCurrency($cookie->id_currency);
 
		if (Tools::getValue('id_product') != "") 
 
			$catSearch						= new Product(Tools::getValue('id_product'));
 
		$category							= $catSearch ? $catSearch->id_category_default : Tools::getValue('id_category', 0);
 
		// Code original
		//$query								= "SELECT count(*) as total FROM `"._DB_PREFIX_."product` p ".($category ? "LEFT JOIN `"._DB_PREFIX_."category_product` c ON (c.`id_product` = p.`id_product`)" : "")." WHERE p.`active` = 1 ".($category ? " AND c.`id_category` = ".(int)($category) : "");
 
		// Copie du code original afin d'essayer de modifier la requete afin d'extraire tous les produits, quelque soit la categorie qui est récuoéré dans l'URL
		// http://www.monwbe.ch/category.php?id_category=4
 
		$query								= "SELECT count(*) as total FROM `"._DB_PREFIX_."product` p ".($category ? "INNER `"._DB_PREFIX_."category_product` c ON (c.`id_product` = p.`id_product`)" : "")." WHERE p.`active` = 1 ";
 
		$result								= Db::getInstance()->s($query);
 
		$nbProd								= $result[0]['total'];
 
		$limit								= 200;
 
		$counter							= ceil($nbProd / $limit) == 1 ? 0 : ceil($nbProd / $limit);
 
		for ($mem = 0; $mem <= $counter; $mem++) {
 
			$start							= $mem == 0 ? 0 : $mem * $limit + 1;
 
			$this->parseProducts($language,$start, $limit,$category, $currency['conversion_rate']);
 
		}
 
 
		if (isset($this->settings['lfpShow']['tags']) && $this->settings['lfpShow']['tags']) {
 
			usort($this->tags, array($this, 'natorder'));
 
			$this->tags						= array_slice($this->tags, 0, $this->settings['lfpTagsNb']);
 
		}
 
		if (isset($this->settings['lfpShow']['attributes']) &&  $this->settings['lfpShow']['attributes'])
 
			foreach ((array) $this->attributes as $key => $list)
 
				uasort($this->attributes[$key]['values'], array($this, 'natorder'));
 
		if (isset($this->settings['lfpShow']['features']) && $this->settings['lfpShow']['features']) {
 
			foreach ((array) $this->features as $key => $list)
 
				natsort($this->features[$key]['values']);
 
			asort($this->features);
 
		}
 
		if (isset($this->settings['lfpShow']['manufacturers']) && $this->settings['lfpShow']['manufacturers']) {
 
			foreach ($this->manufact as $m) {
 
				$mName						= Manufacturer::getNameById($m);
 
				$this->manufacturers[]		= array('id' => $m, 'name' => $mName);
 
			}
 
			uasort($this->manufacturers, array($this, 'natorder'));
 
		}
 
		$this->price['low']					= $this->price['low'] < 0 ? 0 : $this->price['low'];
 
		foreach ($this->settings['lfpPosition'] as $option => $position)
 
			$order[$position] 				= $option;
 
		ksort($order);
 
		$style								= array("bottom", "column");
 
		if (isset($_COOKIE['LFManagerState']) && $this->settings['lfpAllowSaveState'])
 
			if ($_COOKIE['LFManagerState'] == 1)
 
				$this->settings['lfpExpand']['filter'] = 'filter';
 
			else
 
				unset($this->settings['lfpExpand']['filter']);
 
		$smarty->assign(array(
			'price' => isset($this->settings['lfpShow']['price']) && $this->settings['lfpShow']['price'] ? $this->price : "",
			'attributes' => count($this->attributes) > 0 ? $this->attributes : "",
			'features' => count($this->features) > 0 ? $this->features : "",
			'manufacturers' => count($this->manufacturers) > 0 ? $this->manufacturers : "",
			'tags' => count($this->tags) > 0 ? $this->tags : "",
			'collapse' => $this->settings['lfpAllowCollapse'],
			'order' => $order,
			'style' => $style[$this->settings['lfpStyle']],
			'opacity' => $this->settings['lfpOpacity'],
			'expanded' => $this->settings['lfpExpand']));
 
		$out 								= $this->__addJS("var LFsettings = {
														language: {$language},
														category: {$category},
														pricelow: {$this->price['low']},
														pricehigh: {$this->price['high']},
														convert: {$currency['conversion_rate']},
														collapse: {$this->settings['lfpAllowCollapse']},
														compatibility: {$compat}
														}", true);
 
		$out								.= $this->__addJS(($this->_path)."js/livefilter.js", false, false);
 
		return $out.$this->display(__FILE__, 'livefilter.tpl');
 
		}
 
	}
 
	public function hookRightColumn($params) {
 
		return $this->hookLeftColumn($params);
 
	}
 
	public function hookHeader() {
 
		$out 								= $this->__addCSS(($this->_path).'css/jquery-ui-1.7.2.custom.css');
 
		$out								.= $this->__addCSS(($this->_path).'css/livefilter.css');
 
		if (_PS_VERSION_ < '1.4.0') {
 
			$out							.= $this->__addJS(($this->_path).'js/jquery-1.3.2.min.js');
 
			$out							.= $this->__addJS('var $jq = jQuery.noConflict();',true);
 
		}
 
		$out								.= $this->__addJS(($this->_path).'js/jquery-ui-1.7.2.custom.min.js');
 
		echo $out;
 
	}
 
	public function getContent() {
 
		$output 							= '<h2>'.$this->displayName.'</h2>';
 
		$settings_props 					= array("lfpOpacity" => array("valid" => array("empty,int" => $this->l('Invalid opacity value!')),
													  			  "op" => "ratio"),
													"lfpTagsNb" => array("valid" => array("empty,int" => $this->l('Invalid tags number value!')),
															  			  "op" => "trim"),
													"lfpAllowCollapse" => "",
													"lfpAllowSaveState" => "",
													"lfpEmailowner" => array("op" => "trim"),
													"lfpShowOn" => "",
													"lfpShow" => "",
													"lfpPosition" => "",
													"lfpExpand" => "",
													"lfpStyle" => "");
 
		if (Tools::isSubmit('submitLiveFilterDefaults'))
 
			$this->setDefaults();
 
		if (Tools::isSubmit('submitLiveFilter')) {
 
			$errors							= array();
 
			foreach ($settings_props as $set => $val) {
 
				if (!empty($val['valid']) && $val['valid'] != '')
 
				foreach ($val['valid'] as $t => $error) {
 
					if (!$error || $error == '') $error = "An unknown error occured!";
 
					foreach (explode(",",$t) as $test)
 
						switch($test) {
 
							case "int":
 
								if (!is_numeric(Tools::getValue($set)) && !in_array($error,$errors)) $errors[] = $error;
 
							break;
 
							case "empty":
 
								if (Tools::getValue($set) == ""  && !in_array($error,$errors)) $errors[] = $error;
 
							break;
 
							default:
 
								if (!in_array($error,$errors)) $errors[] = $error;
 
							break;
 
						}
 
				}
 
				else continue;
 
			}
 
			if (isset($errors) AND sizeof($errors))
 
				$output .= $this->displayError(implode('<br />', $errors));
 
			else {
 
				foreach ($settings_props as $set => $val) {
 
					if (!empty($val['op']) && $val['op'] != '') {
 
						switch ($val['op']) {
 
							case "implode":
 
								$this->settings[$set] = implode(",",Tools::getValue($set));
 
								break;
 
							case "ratio":
 
								$this->settings[$set] = Tools::getValue($set) / 100;
 
								break;
 
							default:
 
							case "trim":
 
								$this->settings[$set] = trim(Tools::getValue($set));
 
								break; 
 
						}
 
					}
 
					else $this->settings[$set] = Tools::getValue($set);
 
				}
 
				$output 					.= $this->displayConfirmation($this->l('Settings updated'));
 
				$this->saveSettings();
 
			}
 
		}
 
		return $output.$this->displayForm();
 
	}
 
	public function displayForm() {
 
		global $cookie;
 
		$multicheck							= array("price" => "", "features" => "", "attributes" => "", "manufacturers" => "", "tags" => "", "category" => "", "product" => "", "other" => "", "filter" => "", "exprice" => "", "exfeatures" => "", "exmanufacturers" => "", "extags" => "", "exattributes" => "");
 
		$checks 							= array("lfpStyle", "lfpAllowCollapse", "lfpAllowSaveState");
 
		foreach ($checks as $c) {
 
			$check[$c][$this->settings[$c]] = "checked";
 
			$check[$c][1-$this->settings[$c]] = "";
		}
 
		$multichecks 						= array("lfpShowOn", "lfpShow", "lfpExpand");
 
		foreach ($multichecks as $m)
 
			foreach ((array) $this->settings[$m] as $mc)
 
				$multicheck[$mc]		 	= "checked";
 
		$backups 							= $this->getBackups();
 
		if ((bool) array_filter((array) $backups))
 
			foreach ((array)$backups as $i => $b) {
 
				$i++;
 
				$parseBack 					.= "<tr><td>{$i}.</td><td>{$b['module']}</td><td>{$b['version']}</td><td>{$b['date']}</td></tr>";
 
		}
 
		else
 
				$parseBack					= "";
 
		$opacity							= $this->settings['lfpOpacity'] * 100;
 
		$output = <<<STRT
		<fieldset><legend><img src="{$this->_path}logo.gif" alt="" title="" />{$this->l('Configuration')}</legend>
			<div id="navigation" style="width:200px;padding:2px;border:1px solid;float:left;color:#888">
				<ul style="list-style:none;font-size:18px;line-height:40px;padding:0;margin:0;cursor:pointer">
					<li style="margin-bottom:3px; background-color: #FFCC66; color:#000; border-color:#000" class="config_option current" id="Basic"><img src="{$this->_path}settings.png" width="40"/>{$this->l('Settings')}</li>
					<li style="margin-bottom:3px;" class="config_option" id="Display"><img src="{$this->_path}display.png" width="40"/>{$this->l('Display')}</li>
					<li style="margin-bottom:3px;" class="config_option" id="Update"><img src="{$this->_path}updates.png" width="40"/>{$this->l('Update')}</li>
					<li style="margin-bottom:3px;" class="config_option" id="Support"><img src="{$this->_path}support.png" width="40"/>{$this->l('Support')}</li>
				</ul>
			</div>
		<script type="text/javascript">
			function checkUpdates(get) {
				$("span#updateInfo").html('<img id="updateLoad" src="{$this->settings['url']}ajax-loader.gif" />');
				if (!get) {
					$.get("{$this->settings['url']}update.php",{action:"check",moduleName:'{$this->name}'},function(data) {
						var result = JSON.parse(data);
						$("span#updateInfo").html(result.message);
						if (result.update == true) {
							$("input#updateCheck").attr({"onClick":"","value":"Update"}).bind("click",function() {checkUpdates(1)});
						}
					});
				} else {
					var email = $("input#emailowner").val();
					$.get("{$this->settings['url']}update.php",{action:"update",moduleName:"{$this->name}",emailOwner:""+email},function(data) {
						var result = JSON.parse(data);
						$("span#updateInfo").html(result.message);
					});
				}
			}
 
			function showForum() {
				$("div#forumExpand").html("<iframe width='100%' height='400px' src='http://prestashop.endpulse.com/forum/index.php?board=7.0&embed=1'/>").slideDown();
			}
 
			$(document).ready(function() {
				$("li.config_option").click(function() {
					var b = this.id;
					$("div.config_section").hide().stop(true,true);
					$("div#s"+b).fadeIn();
					$("li.config_option").not("#"+this.id).removeClass("current").css({"background-color":"","color":"#888","borderColor":"#888"});
					$(this).addClass("current");
				});
				$("li.config_option").mouseover(function() {
					$(this).css({"background-color":"#FFCC66","color":"#000","borderColor":"#000"});
				});
				$("li.config_option").mouseout(function() {
					if (!$(this).hasClass("current")) $(this).css({"background-color":"","color":"#888","borderColor":"#888"});
				});
				$("#ref_vratio").keyup(function() {
					var b = parseInt($(this).val())/100*parseInt($("#voucherbase").text());
					$("#voucherf").text(b.toFixed(2));
					$("#attention").css("color","blue");
				})
			});
		</script>
		<style>.margin-form {font-size:1em;}</style>
		<form action="{$_SERVER['REQUEST_URI']}" method="post">
			<div class="config_section" id="sBasic" style="float:right;padding:10px;border:1px solid;width:670px;">
				<label>{$this->l('Allow filter collapse:')}</label>
				<div class="margin-form">
					{$this->l('ON')} <input type="radio" {$check['lfpAllowCollapse'][1]} name="lfpAllowCollapse" value="1" />
					{$this->l('OFF')} <input type="radio" {$check['lfpAllowCollapse'][0]} name="lfpAllowCollapse" value="0" />
					<p class="clear">{$this->l('Allow the filter block to be collapsed or not. Filter should be set for "always expanded" in display section. (Default: ON)')}</p>	
				</div>
				<label>{$this->l('Save collapse state:')}</label>
				<div class="margin-form">
					{$this->l('ON')} <input type="radio" {$check['lfpAllowSaveState'][1]} name="lfpAllowSaveState" value="1" />
					{$this->l('OFF')} <input type="radio" {$check['lfpAllowSaveState'][0]} name="lfpAllowSaveState" value="0" />
					<p class="clear">{$this->l('Save the filter collapse state across page reloads for the user. (Default: ON)')}</p>	
				</div>
				<label>{$this->l('Show filter on:')}</label>
				<div class="margin-form">
					<input type="checkbox" {$multicheck['category']} name="lfpShowOn[category]" value="category" /> {$this->l('Category pages')}<br/>
					<input type="checkbox" {$multicheck['product']} name="lfpShowOn[product]" value="product" /> {$this->l('Product pages')}<br/>
					<input type="checkbox" {$multicheck['other']} name="lfpShowOn[other]" value="other" /> {$this->l('Other pages')}<br/>
					<p class="clear">{$this->l('Check on what sections will the filter be displayed (Default: ALL)')}</p>	
				</div>
				<label>{$this->l('Filter options:')}</label>
				<div class="margin-form">
					<input type="checkbox" {$multicheck['price']} name="lfpShow[price]" value="price" /> {$this->l('Price')}<br/>
					<input type="checkbox" {$multicheck['features']} name="lfpShow[features]" value="features" /> {$this->l('Features')}<br/>
					<input type="checkbox" {$multicheck['attributes']} name="lfpShow[attributes]" value="attributes" /> {$this->l('Attributes')}<br/>
					<input type="checkbox" {$multicheck['manufacturers']} name="lfpShow[manufacturers]" value="manufacturers" /> {$this->l('Manufacturers')}<br/>
					<input type="checkbox" {$multicheck['tags']} name="lfpShow[tags]" value="tags" /> {$this->l('Tags')}<br/>
					<p class="clear">{$this->l('Check which product options should be presented to customers for filtering (Default: ALL)')}</p>	
				</div>
				<label>{$this->l('Options position:')}</label>
				<div class="margin-form">
					<input type="text" size="2" name="lfpPosition[price]" value="{$this->settings['lfpPosition']['price']}" /> {$this->l('Price')}<br/>
					<input type="text" size="2" name="lfpPosition[features]" value="{$this->settings['lfpPosition']['features']}" /> {$this->l('Features')}<br/>
					<input type="text" size="2" name="lfpPosition[attributes]" value="{$this->settings['lfpPosition']['attributes']}" /> {$this->l('Attributes')}<br/>
					<input type="text" size="2" name="lfpPosition[manufacturers]" value="{$this->settings['lfpPosition']['manufacturers']}" /> {$this->l('Manufacturers')}<br/>
					<input type="text" size="2" name="lfpPosition[tags]" value="{$this->settings['lfpPosition']['tags']}" /> {$this->l('Tags')}<br/>
					<p class="clear">{$this->l('Set position for each of the options. Options will be displayed from lowest to highest position (Default: 1-2-3-4-5)')}</p>	
				</div>
				<label>{$this->l('# of Tags:')}</label>
				<div class="margin-form">
					<input type="text" size="2" name="lfpTagsNb" value="{$this->settings['lfpTagsNb']}" /><br/>
					<p class="clear">{$this->l('Set the number of tags to be displayed, in alphabetical order. (Default: 5)')}</p>	
				</div>
			</div>
			<div class="config_section" id="sDisplay" style="float:right;position:relative;padding:10px;border:1px solid;width:670px;display:none">
				<label>{$this->l('Block style:')}</label>
				<div class="margin-form">
					<input type="radio" {$check['lfpStyle'][1]} name="lfpStyle" value="1" /> {$this->l('Column')}<br/>
					<input type="radio" {$check['lfpStyle'][0]} name="lfpStyle" value="0" /> {$this->l('Bottom (fixed)')}
					<p class="clear">{$this->l('Select which type of filter style will be displayed - cloumn or fixed at the bottom of the browser (Default: Column)')}</p>	
				</div>
				<label>{$this->l('Show expanded:')}</label>
				<div class="margin-form">
					<input type="checkbox" {$multicheck['filter']} name="lfpExpand[filter]" value="filter" /> {$this->l('Filter (entire block)')}<br/>
					<input type="checkbox" {$multicheck['exprice']} name="lfpExpand[price]" value="exprice" /> {$this->l('Price')}<br/>
					<input type="checkbox" {$multicheck['exfeatures']} name="lfpExpand[features]" value="exfeatures" /> {$this->l('Features')}<br/>
					<input type="checkbox" {$multicheck['exattributes']} name="lfpExpand[attributes]" value="exattributes" /> {$this->l('Attributes')}<br/>
					<input type="checkbox" {$multicheck['exmanufacturers']} name="lfpExpand[manufacturers]" value="exmanufacturers" /> {$this->l('Manufacturers')}<br/>
					<input type="checkbox" {$multicheck['extags']} name="lfpExpand[tags]" value="extags" /> {$this->l('Tags')}<br/>
					<p class="clear">{$this->l('Check which filter options should always be expanded and if filter block is displayed expanded (Default: Filter & Price)')}</p>	
				</div>
				<label>{$this->l('Block opacity:')}</label>
				<div class="margin-form">
					<input type="text" size="2" name="lfpOpacity" value="{$opacity}" />%
					<p class="clear">{$this->l('Set the opacity of the filter block - only valid for the bottom style (Default: 75%)')}</p>	
				</div>
			</div>
			<div class="config_section" id="sUpdate" style="float:right;position:relative;padding:10px;border:1px solid;width:670px;display:none">
				<label>{$this->l('Email address :')}</label>
				<div class="margin-form">
					<input type="text" id="emailowner" size="35" name="lfpEmailowner" value="{$this->settings['lfpEmailowner']}" />
					<p class="clear">{$this->l('Registered customer email!')}</p>
				</div>
				<label>{$this->l('Check for updates :')}</label>
				<div class="margin-form">
					<input type="button" id="updateCheck" size="35" name="check" value="{$this->l('Check for new version')}" onClick="checkUpdates(0);"/> <span id="updateInfo"></span>
				</div>
				<div>
					<table style="width:100%;border:1px solid">
						<tr><td colspan=4 align="center"><strong>{$this->l('Backups')}</strong></td></tr>
						<tr><td>#</td><td>{$this->l('Name')}</td><td>{$this->l('Version')}</td><td>{$this->l('Date')}</td></tr>
						{$parseBack}
					</table>
				</div>
			</div>
			<div class="config_section" id="sSupport" style="float:right;position:relative;padding:10px;border:1px solid;width:670px;display:none">
				<label>{$this->l('Support website :')}</label>
				<div class="margin-form">
					<a target="_blank" href="http://prestashop.endpulse.com"><strong>http://prestashop.endpulse.com</strong></a>
				</div>
				<label>{$this->l('Support Email :')}</label>
				<div class="margin-form">
					<a href="mailto:support@endpulse.com"><strong>support@endpulse.com</strong></a> 
				</div>
				<div>
					<table style="width:100%;">
						<tr><td colspan=4 align="center" style="cursor:pointer" onClick="showForum()"><strong>{$this->l('Support Forum (click to expand)')}</strong></td></tr>
						<tr><td colspan=4 align="center"><div id="forumExpand" style="display:none"></div>
					</table>
				</div>
			</div>
			</fieldset><br/>
				<center>
					<input type="submit" name="submitLiveFilter" value="{$this->l('Save settings')}" class="button" />
					<input type="submit" name="submitLiveFilterDefaults" value="{$this->l('Restore Defaults')}" class="button" />
				</center>
STRT;
 
		return $output;
 
	}
 
	public function parseProducts($language, $start, $limit, $category, $convert) {
 
		$products							= Product::getProducts($language,$start, $limit,'id_product','ASC', $category, true);
 
		$productPool						= "";
 
		foreach ((array)$products as $p) {
 
			$IDprod[]						= $p['id_product'];
 
			if (isset($this->settings['lfpShow']['price']) && $this->settings['lfpShow']['price']) {
 
				$prodPrice					= $p['price'] * (1 + $p['tax_rate'] / 100) * $convert;
 
				$this->price['low']			= ($this->price['low'] == 0 || $prodPrice < $this->price['low']) ? floor($prodPrice - 1) : $this->price['low'];
 
				$this->price['high']		= ($this->price['high'] == 0 || $prodPrice > $this->price['high']) ? ceil($prodPrice + 1) : $this->price['high'];
 
			}
 
			if (isset($this->settings['lfpShow']['manufacturers']) &&  $this->settings['lfpShow']['manufacturers'])
 
				if (!isset($this->manufact) || (!in_array($p['id_manufacturer'],$this->manufact) && $p['id_manufacturer'] != 0))
 
					$this->manufact[]		= $p['id_manufacturer'];
 
		}
 
		if (isset($IDprod))
 
			$productPool					= implode(",", $IDprod);
 
		if (isset($this->settings['lfpShow']['tags']) && $this->settings['lfpShow']['tags']) {
 
				$query						= 'SELECT  COUNT(*) as cnt, t.name FROM '._DB_PREFIX_.'product_tag pt
												LEFT JOIN '._DB_PREFIX_.'tag t ON (pt.id_tag = t.id_tag AND t.id_lang = '.(int)$language.')
												WHERE pt.id_product IN ('.$productPool.') AND t.name <> ""
												GROUP BY t.name
												ORDER BY cnt DESC';
 
				$tags						= Db::getInstance()->s($query);
 
				foreach ((array) $tags as $t)
 
					if (!isset($tagsArr) || !in_array($t['name'], $tagsArr))
 
						$tagsArr[]			= $t['name'];
 
				$this->tags 				= array_unique(array_merge((array) $this->tags, array_filter((array) $tagsArr)));
 
		}
 
		if (isset($this->settings['lfpShow']['features']) && $this->settings['lfpShow']['features']) {
 
				$query						=  'SELECT pf.id_feature_value, name, value, pf.id_feature
												FROM '._DB_PREFIX_.'feature_product pf
												LEFT JOIN '._DB_PREFIX_.'feature_lang fl ON (fl.id_feature = pf.id_feature AND fl.id_lang = '.(int)$language.')
												LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.(int)$language.')
												WHERE pf.id_product IN ('.$productPool.')';
 
				$feat						= Db::getInstance()->s($query);
 
				if (!empty($feat))
 
				foreach ((array) $feat as $f) {
 
					if (!array_keys((array) $this->features, $f['id_feature'])) {
 
						$this->features[$f['id_feature']]['name']	= $f['name'];
 
						$this->features[$f['id_feature']]['header'] = preg_replace("/[^a-zA-Z0-9]/", "", $f['name']);
 
					}
 
					if (!isset($this->features[$f['id_feature']]['values']) || !in_array($f['value'], (array) $this->features[$f['id_feature']]['values']))
 
						$this->features[$f['id_feature']]['values'][$f['id_feature_value']] = $f['value'];
 
				}
 
		}
 
		if (isset($this->settings['lfpShow']['attributes']) &&  $this->settings['lfpShow']['attributes']) {
 
			$query							= '	SELECT ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, agl.`public_name` AS public_group_name, a.`id_attribute`, al.`name` AS attribute_name,
												a.`color` AS attribute_color, pa.`id_product_attribute`, pa.`quantity`, pa.`price`, pa.`ecotax`, pa.`weight`, pa.`default_on`, pa.`reference` 
												FROM `'._DB_PREFIX_.'product_attribute` pa
												LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute`
												LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute`
												LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON ag.`id_attribute_group` = a.`id_attribute_group`
												LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON a.`id_attribute` = al.`id_attribute`
												LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON ag.`id_attribute_group` = agl.`id_attribute_group`
												WHERE pa.`id_product` IN ('.$productPool.')
												AND al.`id_lang` = '.(int)($language).'
												AND agl.`id_lang` = '.(int)($language).'
												ORDER BY al.`name`';
 
			$attr							= Db::getInstance()->s($query);
 
			if (!empty($attr))
 
			foreach ((array) $attr as $a) {
 
				if (!array_keys((array) $this->attributes, $a['id_attribute_group'])) {
 
					$this->attributes[$a['id_attribute_group']]['name']	= $a['public_group_name'];
 
					$this->attributes[$a['id_attribute_group']]['header']= preg_replace("/[^a-zA-Z0-9]/", "", $a['public_group_name']);
 
				}
 
				if (!isset($this->attributes['values']) || !array_keys((array) $this->attributes['values'], $a['id_attribute']))
 
					$this->attributes[$a['id_attribute_group']]['values'][$a['id_attribute']] = array('name' => $a['attribute_name'], 'color' => $a['attribute_color']);
 
			}
 
		}
 
	}
 
	public function uninstall()
	{
 
		parent::uninstall();
 
		Configuration::deleteByName('LFP_SETTINGS');
 
		 return true;				
	}
 
	public function saveSettings() {
 
		if (!empty($this->settings))
 
			return Configuration::updateValue('LFP_SETTINGS',serialize($this->settings));
 
		return false;
 
	}
 
	public function setDefaults() {
 
		$this->settings['lfpEmailowner']	= (isset($this->settings['lfpEmailowner'])) ? $this->settings['lfpEmailowner'] : "";
 
		$this->settings['lfpShowOn'] 		= array('category' => 'category', 'product' => 'product', 'other' => 'other');
 
		$this->settings['lfpShow'] 			= array('filter' => 'filter', 'price' => 'price', 'features' => 'features', 'attributes' => 'attributes', 'manufacturers' => 'manufacturers', 'tags' => 'tags');
 
		$this->settings['lfpExpand']		= array('price' => 'exprice', 'filter' => 'filter');
 
		$this->settings['lfpPosition']		= array('price' => 1, 'features' => 2, 'attributes' => 3, 'manufacturers' => 4, 'tags' => 5);
 
		$this->settings['lfpStyle']			= 1;
 
		$this->settings['lfpAllowSaveState']= 1;
 
		$this->settings['lfpAllowCollapse']	= 1;
 
		$this->settings['lfpTagsNb']		= 5;
 
		$this->settings['lfpOpacity']		= .75;
 
 
	}
 
	public function getBackups() {
 
		$files 								= glob(_PS_MODULE_DIR_."/{$this->name}/backups/*");
 
		foreach ((array)$files as $f) {
 
			$fparts 						= pathinfo($f);
 
			$sections 						= explode("_",$fparts['filename']);
 
			$backups[] 						= array('module' => $sections[1],
													'version' => str_replace("-",".",$sections[2]),
													'date' => date("d M Y H:i",$sections[3]));
 
		}
 
		return (isset($backups)) ? $backups : "";
	}
 
	public function getVersion() {
 
		return $this->version;
 
	}
 
	public function natorder($a,$b) {
 
   		return strnatcmp($a['name'], $b['name']);
 
	} 	
 
	public function __addCSS($file) {
 
		if (method_exists('Tools','addCSS'))
 
			Tools::addCSS($file);
 
		else
 
			echo "<link type='text/css' href='{$file}' rel='stylesheet' />";
 
	}
 
	public function __addJS($file, $string = false, $useTools = true) {
 
		if ($string) 
 
			return "<script type='text/javascript'>{$file}</script>";
 
		elseif (method_exists('Tools','addJS') && $useTools)
 
			Tools::addJS($file);
 
		else
 
			return "<script type='text/javascript' src='{$file}'></script>";
 
	}
 
}
?>
I also add $_GET['id_category']=1; in order to play with the value but if I do
$_GET['id_category']=""
$_GET['id_category']=
$_GET['id_category']=%

it generate an error that I can not see. The web page is white and empty

Thank
Cheers
__________________
Il ne suffit pas de tout savoir. Vouloir et persévérer, c'est déjà presque tout!
pierrot10 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2012, 15h23   #8
Modérateur
 
Avatar de CinePhil
 
Homme Philippe Leménager
Ingénieur d'études en informatique
Inscription : août 2006
Messages : 11 029
Détails du profil
Informations personnelles :
Nom : Homme Philippe Leménager
Âge : 48
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Ingénieur d'études en informatique
Secteur : Enseignement

Informations forums :
Inscription : août 2006
Messages : 11 029
Points : 18 331
Points : 18 331
Envoyer un message via MSN à CinePhil
Il manque JOIN après INNER :
Code :
1
2
3
4
5
6
$query = "
	SELECT count(*) as total 
	FROM "._DB_PREFIX_."product p ".
	($category ? "INNER JOIN "._DB_PREFIX_."category_product c ON c.id_product = p.id_product" : "")." 
	WHERE p.active = 1 
";
J'en ai profité pour remettre en forme ce code et supprimer les parenthèses et apostrophes inversées inutiles.
Je me demande aussi à quoi sert le DB_PREFIX. C'est une BDD d'un CMS ?
__________________
Philippe Leménager. Ingénieur d'étude à l'École Nationale de Formation Agronomique.
Mon blog sur la conception des BDD, le langage SQL, le PHP avec Zend Framework...
« Ce que l'on conçoit bien s'énonce clairement, et les mots pour le dire arrivent aisément ». (Nicolas Boileau)
À la maison comme au bureau, j'utilise Mandriva Linux ou Mageïa ! Soutenons l'industrie logicielle française !
Linuxiens, comptez-vous !
CinePhil est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2012, 15h50   #9
Débutant
 
Inscription : mai 2005
Messages : 1 957
Détails du profil
Informations personnelles :
Localisation : Suisse

Informations forums :
Inscription : mai 2005
Messages : 1 957
Points : 615
Points : 615
salut.
Merci pour ton aide, mais ca pas l'air de marché

J'utilise Prestashop, un "CMS" pour l'e-commerce. C'est un module de filtre de produit que j'ai acqui que j'essaye de modifier afin qu'il filtre tous les produits de mon stock et non pas en fonction de la Catégorie.

Mais j'ai suivi ta correction et apparemment ca n'a rien changé. Mais je vais encore supprimé tout mon cache. Si ca se trouve je me fais avoir avec le cache car Prestashop est assez fort avec ca


_DB_PREFIX_, c'est une nvalauer prédéfinie qui correspon au préfix de mes table. Dans mon cas, c'est égal à "ps_".
Par exemple, si j'ai une table 'categorie', ben en fait ca sera "ps_categorie".

Encore merci pour ton aide
__________________
Il ne suffit pas de tout savoir. Vouloir et persévérer, c'est déjà presque tout!
pierrot10 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2012, 17h21   #10
Modérateur
 
Avatar de CinePhil
 
Homme Philippe Leménager
Ingénieur d'études en informatique
Inscription : août 2006
Messages : 11 029
Détails du profil
Informations personnelles :
Nom : Homme Philippe Leménager
Âge : 48
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Ingénieur d'études en informatique
Secteur : Enseignement

Informations forums :
Inscription : août 2006
Messages : 11 029
Points : 18 331
Points : 18 331
Envoyer un message via MSN à CinePhil
Donc tu n'as carrément pas besoin de la jointure avec la table category !
Code :
1
2
3
4
5
$query = "
	SELECT count(*) as total 
	FROM "._DB_PREFIX_."product p 
	WHERE p.active = 1 
";
__________________
Philippe Leménager. Ingénieur d'étude à l'École Nationale de Formation Agronomique.
Mon blog sur la conception des BDD, le langage SQL, le PHP avec Zend Framework...
« Ce que l'on conçoit bien s'énonce clairement, et les mots pour le dire arrivent aisément ». (Nicolas Boileau)
À la maison comme au bureau, j'utilise Mandriva Linux ou Mageïa ! Soutenons l'industrie logicielle française !
Linuxiens, comptez-vous !
CinePhil est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/01/2012, 11h01   #11
Membre du Club
 
Avatar de LeGnome12
 
Développeur Web
Inscription : mai 2008
Messages : 78
Détails du profil
Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : mai 2008
Messages : 78
Points : 61
Points : 61
Bonjour,

Je pense qu'avec des quotes, ça résoudrait ton problème.

Code :
1
2
3
4
 
...
$where[]	 = "cp.id_category = '%' ";
...
Ce n'est pas certain que ça fonctionne sans problème. Surtout si id_category est un integer (ce que je suppose). Mais ça ne mange pas de pain de tester.

LeGnome
LeGnome12 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 03h47.


 
 
 
 
Partenaires

Hébergement Web