Hi,
I am trying to get php display randomly 6 products from my data base.
Here is the code I am trying to implement :
Code: Select all
<?php require_once('Connections/imexso.php'); ?>
<?php
$promo_find = $imexso->newFindCommand('WEB - Homepage');
$promo_findCriterions = array('Affaire du jour'=>'oui','Statut'=>'a vendre','ID VN'=>'VO',);
foreach($promo_findCriterions as $key=>$value) {
$promo_find->AddFindCriterion($key,$value);
}
$result = $promo_find->execute();
$records = $result->getRecords();
$j = ( count( $records ) >=6 )? 6 : count($records);
for($i=0; $i<$j ; $i++ ) {
$k = rand(0,count($records)-1);
if( in_array($k,$taken) ) $i--;
else {
$taken[] = $k;
}
}
foreach($taken as $array_pos) {
$cur_record = $records[$array_pos];
$cur_record->getField('MARQUE');
}
?>
Could someone please help me understand this code and get it work?!Warning: in_array() [function.in-array]: Wrong datatype for second argument in /data/WebSites/imexso.com/test.php on line 14
Thank you,
Adrian.
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: