NameSilo

Top rated

Spaceship Spaceship
Watch

zielak

VIP Member
Impact
7
I have this code to display top rated media on my website. It;s displaying 10 top rated medias but I want to change this code to display 2 medias in a row than next 2 in another row and so on, something like this:

1 2
3 4
5 6...

Instead of:
1
2
3...

I can't figure out how to do this so any help apreciated :)

Code:
<?php

$text = "";

$medias = get_medias("order=rating&sort=DESC&limitstart=0&limitnum="._sp($themecfg['topmenusnumber'])."&htmlize=true");

$num = count($medias);

$i = 0;
foreach ($medias as $media) {
	++$i;

	if ($i < 10) {
		$text .= "";
	} else {
		$text .= "<b>".$i.".</b> ";
	}

	$link = get_media_link("id="._sp($media['id']));

	$media['name'] = shrinktext($media['name'], 14);

	$text .= "<a href='".$link."'><img src='[imgdir]".$media['nameid'].".png' width='60;' height='48;' style='border: 1px solid #000000;' /></a><br/>";

	// - ".$media['rating']."
}

lcb("", 4, $text);

?>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains — AI StorefrontUnstoppable Domains — AI Storefront
Here you go:

PHP:
<?php

$text = '<table width = "100%" cellspacing = "5">';

$medias = get_medias("order=rating&sort=DESC&limitstart=0&limitnum="._sp($themecfg['topmenusnumber'])."&htmlize=true");

$num = count($medias);

$i = 0;
$row=1;
foreach ($medias as $media) {
	++$i;

	if ($i < 10) {
		$text .= "";
	} else {
		$text .= "<b>".$i.".</b> ";
	}

	$link = get_media_link("id="._sp($media['id']));

	$media['name'] = shrinktext($media['name'], 14);

	if($row == 1){
		$text .= "<tr><td><a href='".$link."'><img src='[imgdir]".$media['nameid'].".png' width='60;' height='48;' style='border: 1px solid #000000;' /></a></td>";
		$row = 2;
	}elseif($row == 2){
		$text .= "<td><a href='".$link."'><img src='[imgdir]".$media['nameid'].".png' width='60;' height='48;' style='border: 1px solid #000000;' /></a></td></tr>";
		$row = 1;
	}

	// - ".$media['rating']."
}

$text.= '</table>';

lcb("", 4, $text);

?>
 
1
•••
Thank you, that's exactly what I wanted.
Rep added :)
 
0
•••

We're social

Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back