PHP ver gevorderde |
|
<?PHP
$iLimit = 5;
$sql = "SELECT * FROM member ORDER BY loginName DESC LIMIT " . $iLimit;
$query = mysql_query( $sql ) or die( mysql_error() );
$i = 0;
while($row = mysql_fetch_assoc($query))
{
$i++;
if ($i != $iLimit);
{
$sSplit = ", ";
}
else
{
$sSplit = "";
}
echo $row['user_name'] . " " . $row['foto'] . $sSplit;
}
?>
<?PHP $iLimit = 5; $sql = "SELECT * FROM member ORDER BY loginName DESC LIMIT " . $iLimit; $i = 0; { $i++; if ($i != $iLimit); { $sSplit = ", "; } else { $sSplit = ""; } echo $row['user_name'] . " " . $row['foto'] . $sSplit; } ?>
Resulteert in:
Naam1 [Foto1], Naam2 [Foto2], Naam3 [Foto 3], Naam4 [Foto4], Naam5 [Foto5]
Als je het plaatje en de naam onder elkaar wilt, zou je dit bijvoorbeeld met tabellen kunnen doen.
<?PHP
$sql = "SELECT * FROM member ORDER BY loginName DESC LIMIT 5";
$query = mysql_query( $sql ) or die( mysql_error() );
echo '<table cellspacing="0" cellpadding="0">';
echo '<tr>';
while($row = mysql_fetch_assoc($query))
{
echo '<td>';
echo $row['foto'] . '<br />';
echo $row['user_name'];
echo '</td>';
}
echo '</tr>';
echo '</table>';
?>
<?PHP $sql = "SELECT * FROM member ORDER BY loginName DESC LIMIT 5"; echo '<table cellspacing="0" cellpadding="0">'; { echo $row['foto'] . '<br />'; } ?>
Reulteert in:
[Foto1] [Foto2] [Foto3] [Foto4] [Foto5]
Naam1 Naam2 Naam3 Naam4 Naam5
[Foto1] [Foto2] [Foto3] [Foto4] [Foto5] Naam1 Naam2 Naam3 Naam4 Naam5
|