Jump to content

numbered list in php


kurtos123

Recommended Posts

I am displaying the top 10 games on my website but i want this list numbered from 1 to 10.

How do i inplement this in my code ? Is it posible also the ad numbered images, and how do i do that?

 

Here is my code so far:

 

<?php
include "config.php";
$rQuery = mysql_query("SELECT * FROM " . $pre . "$sqlgame WHERE cijfer / stemmen >= 10 ORDER BY views DESC LIMIT 10");
while($aGame = mysql_fetch_assoc($rQuery))
{
  if($aGame['cijfer'] != 0 AND $aGame['stemmen'] != 0)
  {
    $cijfer = floor($aGame['cijfer'] / $aGame['stemmen']);
  }
  else
  {
    $cijfer = 0;
  }
  $sSpelNaam = str_replace(" ", "-",$aGame['name']);
  echo "<font color='#333333'>• <a href=\"http://www.crocgame.com/games.php/" . $sSpelNaam . ".html\" target='blank' onmouseover=\"ddrivetip('<img src=\'" . $aGame['screenshoturl'] . "\' width=\'170\' height=\'140\' alt=\'" . $aGame['name'] . "\'><br /><b>" . $aGame['name']  . "</b>');\" onmouseout='hideddrivetip();'>" . $aGame['name'] . " " . $aGame['extra'] . "</a></font><br />" . PHP_EOL;
}
?>
 

Link to comment
Share on other sites

On way would be to use counter

// initiate counter
$i = 0;

while($aGame = mysql_fetch_assoc($rQuery)
{
    if($aGame['cijfer'] != 0 AND $aGame['stemmen'] != 0)
    {
        $cijfer = floor($aGame['cijfer'] / $aGame['stemmen']);
    }
    else
    {
        $cijfer = 0;
    }
    $sSpelNaam = str_replace(" ", "-",$aGame['name']);

    // increment counter by one
    $i++;

    // output counter
    echo "$i. <font color='#333333'>• <a href=\"http://www.crocgame.com/games.php/" . $sSpelNaam . ".html\" target='blank' onmouseover=\"ddrivetip('<img src=\'" . $aGame['screenshoturl'] . "\' width=\'170\' height=\'140\' alt=\'" . $aGame['name'] . "\'><br /><b>" . $aGame['name']  . "</b>');\" onmouseout='hideddrivetip();'>" . $aGame['name'] . " " . $aGame['extra'] . "</a></font><br />" . PHP_EOL;

}

The code will increment $i by one each time a row is outputted in the while loop

 

Or you could output the results in a HTML ordered list

 

 

Is it posible also the ad numbered images, and how do i do that?

Yes, depending on how have named your images, I assume you have named like 1.png, 2.png etc, you can change  echo "$i.   in my example code above to to be  echo "<img src=\"$i.png\" />

Link to comment
Share on other sites

:confused: Updated my browser and got error message

Parse error: syntax error, unexpected '{' in /home/crocgame/domains/crocgame.com/public_html/beste_games1.php on line 7

I am bad in php so please help me further...

Many thanks for help!

 

<?php
include "config.php";
// initiate counter
$i = 0;

while($aGame = mysql_fetch_assoc($rQuery)
{
    if($aGame['cijfer'] != 0 AND $aGame['stemmen'] != 0)
    {
        $cijfer = floor($aGame['cijfer'] / $aGame['stemmen']);
    }
    else
    {
        $cijfer = 0;
    }
    $sSpelNaam = str_replace(" ", "-",$aGame['name']);

    // increment counter by one
    $i++;

    // output counter
    echo "$i. <font color='#333333'>• <a href=\"http://www.crocgame.com/games.php/" . $sSpelNaam . ".html\" target='blank' onmouseover=\"ddrivetip('<img src=\'" . $aGame['screenshoturl'] . "\' width=\'170\' height=\'140\' alt=\'" . $aGame['name'] . "\'><br /><b>" . $aGame['name']  . "</b>');\" onmouseout='hideddrivetip();'>" . $aGame['name'] . " " . $aGame['extra'] . "</a></font><br />" . PHP_EOL;

}

?>

Link to comment
Share on other sites

Code so far:

 

<?php
include "config.php";
// initiate counter
$i = 0;
$rQuery = mysql_query("SELECT * FROM " . $pre . "$sqlgame WHERE cijfer / stemmen >= 10 ORDER BY views DESC LIMIT 10");
while($aGame = mysql_fetch_assoc($rQuery))
    if($aGame['cijfer'] != 0 AND $aGame['stemmen'] != 0)
    {
        $cijfer = floor($aGame['cijfer'] / $aGame['stemmen']);
    }
    else
    {
        $cijfer = 0;
    }
    $sSpelNaam = str_replace(" ", "-",$aGame['name']);

    // increment counter by one
    $i++;

    // output counter
    echo "$i.<font color='#333333'>• <a href=\"http://www.crocgame.com/games.php/" . $sSpelNaam . ".html\" target='blank' onmouseover=\"ddrivetip('<img src=\'" . $aGame['screenshoturl'] . "\' width=\'170\' height=\'140\' alt=\'" . $aGame['name'] . "\'><br /><b>" . $aGame['name']  . "</b>');\" onmouseout='hideddrivetip();'>" . $aGame['name'] . " " . $aGame['extra'] . "</a></font><br />" . PHP_EOL;

}
?>
 

 

STill not working with above code get mysql error: Parse error: syntax error, unexpected '}' in/home/crocgame/domains/crocgame.com/public_html/beste_games1.phpon line 23                     Please help !

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.