ALaure.net

Search

Mon cinéma

Last updated: novembre 24th, 2010


term_relationships tr, $wpdb->term_taxonomy tt , $wpdb->posts
LEFT JOIN $wpdb->postmeta pm1 ON (ID = pm1.post_id AND pm1.meta_key = ‘Rating’)
WHERE tr.object_id = ID
AND tr.term_taxonomy_id = tt.term_taxonomy_id
AND tt.term_id = 11
ORDER BY post_date DESC »;
$items = mysql_query($sql);
$count = mysql_num_rows($items);

define(‘MAX_COVERS_PER_ROW’, 5);

$covers = array();
while ($item = mysql_fetch_array($items)) {
$title = strip_tags($item[« title »]);
$rating = $item[« rating »] ? $item[« rating »] : 0 ;
$tableau = ‘

‘;
if (‘publish’ == $item[« status »]) {
$tableau .= ‘‘;
}
$tableau .= ‘Couverture de “'.$title.'”‘;
if (‘publish’ == $item[« status »]) {
$tableau .= ‘
‘;
}
$tableau .= ‘
'.$rating.'

‘;
$covers[] = $tableau;
}

if ($count % MAX_COVERS_PER_ROW) $covers = array_merge(array_fill(0, MAX_COVERS_PER_ROW – $count % MAX_COVERS_PER_ROW, ‘

‘), $covers);

$y = 0;
$table = ‘

‘;
foreach($covers as $cover) {
++$y;
if (1 == $y % MAX_COVERS_PER_ROW) $table .= ‘

‘;
$table .= $cover;
if (0 == $y % MAX_COVERS_PER_ROW) $table .= ‘

‘;
}
$table .= ‘

‘;

echo $table;
?>