*

Recent

Author Topic: Top 5 games  (Read 12410 times)

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Top 5 games
« on: September 12, 2011, 01:54:04 PM »
This mod will display the top five games, their play count and will link to the games. Just add this code on the template.php in one of the side bar tables.

Code: [Select]
        <td class="header2">Top 5 Games</td>
</tr>

<tr>
<td class="content2">
                   <?php
$minViews 0;
    $count1 0;
$newest2 "SELECT name, views, ID FROM dd_games WHERE `active`='1' AND Views>$minViews ORDER BY Views DESC";
$newest1 sqlcache('newest'$cachelife$newest2);
foreach($newest1 as $row1){
$newestname preg_replace('#\W#''-'$row1['name']);
if($count1<=4){
echo '<ul class=\'catmenu\'>
<li>'
;
if ($seo_on == 1){
echo "<a href='".$domain."/play/".$row1["ID"]."-".$newestname.".html'>" .$row1["name"]." - (" .$row1["views"].")</a>";
}else{
echo "<a href='".$domain."/index.php?action=play&amp;ID=" .$row1["ID"]. "'>".$row1["name"]." - (" .$row1["views"].")</a>";
                            }
echo '</li>
</ul>'
;}
$count1++;
}
echo '<br />';
if ($seo_on == 1){
echo '&nbsp;<a href=\''.$domain.'/mostplayed/\' title=\'Most Played\'>View more >>></a>';}else{
echo '&nbsp;<a href=\''.$domain.'/index.php?action=mostplayed\' title=\'Most Played\'>View more >>></a>';}
?>

</td>

This code will display the 5 latest games

Code: [Select]
<tr>
                 <td class="header2">Latest Games</td>
</tr>
<tr>
<td class="content2">                            
                   <?php
    $count2 0;
$latest2 "SELECT name, dateadded, ID FROM dd_games  WHERE `active`='1' ORDER BY dateadded DESC";
$latest1 sqlcache('latest'$cachelife$latest2);
foreach($latest1 as $row2){
$latestname preg_replace('#\W#''-'$row2['name']);
if($count2<=4){
echo '<ul class=\'catmenu\'>
<li>'
;
if ($seo_on == 1){
echo "<a href='".$domain."/play/".$row2["ID"]."-".$latestname.".html'>" .$row2["name"]. "</a>";
}else{
echo "<a href='".$domain."/index.php?action=play&amp;ID=" .$row2["ID"]. "'>" .$row2["name"]. "</a>";
                            }
echo '</li>
</ul>'
;}
$count2++;
}
echo '<br />';
if ($seo_on == 1){
echo '&nbsp;<a href=\''.$domain.'/newest/\' title=\'Newest\'>View more >>></a>';}else{
echo '&nbsp;<a href=\''.$domain.'/index.php?action=newest\' title=\'Newest\'>View more >>></a>';}
?>

</td>
</tr>
« Last Edit: February 09, 2012, 06:37:09 PM by spagetiokillers »

kurt

  • Developer
  • Hero Member
  • ******
  • Posts: 634
  • Force: +16/-1
Re: Top 5 games
« Reply #1 on: September 12, 2011, 04:56:41 PM »
Kewl. Thanks!

soulwebsites

  • Jr. Member
  • **
  • Posts: 71
  • Force: +0/-0
    • Jamsite
Re: Top 5 games
« Reply #2 on: October 15, 2011, 07:50:24 AM »
Hi spagetiokiller I was wondering if you could help I have used your code on my site slightly changing it to fit in the centre rather than the sides but im not very good with php. My question is how do I add the image to the side of the game?

Below is how the code currently looks I would like to add it to the top of each title if possible?

http://jamsiteproject.comli.com/ - Example of what it currently looks like

Code: [Select]
echo '
      <table width=\'100%\' border=\'0\'>
      <tr>
      <td class=\'header\'>Top 5 Games</td>
</tr>

<tr>
<td class=\'content2\'>';

$minViews = 5;
$queryt = "SELECT Name, Views, ID FROM dd_games WHERE Views>$minViews ORDER BY Views DESC";
$resultt = mysql_query($queryt);
if (!$resultt) {
//do something if nothing is returned from the db
echo'An error occured';
}else{
if ($seo_on == 1){
echo '<div class=\'catmenu\'>';
for ($i=0; $i<5; $i++){
echo "<a href='".$domain."/play/".mysql_result($resultt, $i, "ID")."-".mysql_result($resultt, $i, "Name").".html'>" . mysql_result($resultt, $i, "Name") . " - (" . mysql_result($resultt, $i, "Views") . ")  </a>";}
echo '</div>';
                        echo '<br />';
                        echo '<a href=\''.$domain.'/mostplayed/\' title=\'Most Played\'>View more >>></a>';
}else{
echo '<div class=\'catmenu\'>';
for ($i=0; $i<5; $i++){
echo "<a href='".$domain."/index.php?action=play&ID=" . mysql_result($resultt, $i, "ID") . "'>" . mysql_result($resultt, $i, "Name") . " - (" . mysql_result($resultt, $i, "Views") . ")  </a>";}
echo '</div>';
                            echo '<br />';
                            echo '<a href=\''.$domain.'/index.php?action=mostplayed\' title=\'Most Played\'>View more >>></a>';}}

echo '</td></tr></table>';

Thanks for any help  ;D

Azedbutt

  • Newbie
  • *
  • Posts: 38
  • Force: +0/-0
    • Loose Game
Re: Top 5 games
« Reply #3 on: October 15, 2011, 09:56:39 AM »
As you mentioned in your first message - Could you please create a mod that will show New 5 games.

Also is there anyway we could show the top 5 games with images and in the centre of the website in a table instead of just text on the side?

Thanks for sharing the script though

soulwebsites

  • Jr. Member
  • **
  • Posts: 71
  • Force: +0/-0
    • Jamsite
Re: Top 5 games
« Reply #4 on: October 15, 2011, 10:10:58 AM »
Hi Azedbutt im no pro at this but I have done something like what you are asking for:

In base_home.php

search for:
Code: [Select]
$count = 0;
Just above this enter the following

Code: [Select]
echo '
      <table width=\'100%\' border=\'0\'>
      <tr>
      <td class=\'header\'>Top 5 Games</td>
</tr>

<tr>
<td class=\'content2\'>';

$minViews = 5;
$queryt = "SELECT Name, Views, ID FROM dd_games WHERE Views>$minViews ORDER BY Views DESC";
$resultt = mysql_query($queryt);
if (!$resultt) {
//do something if nothing is returned from the db
echo'An error occured';
}else{
if ($seo_on == 1){
echo '<div class=\'catmenu\'>';
for ($i=0; $i<5; $i++){
echo "<a href='".$domain."/play/".mysql_result($resultt, $i, "ID")."-".mysql_result($resultt, $i, "Name").".html'>" . mysql_result($resultt, $i, "Name") . " - (" . mysql_result($resultt, $i, "Views") . ")  </a>";}
echo '</div>';
                        echo '<br />';
                        echo '<a href=\''.$domain.'/mostplayed/\' title=\'Most Played\'>View more >>></a>';
}else{
echo '<div class=\'catmenu\'>';
for ($i=0; $i<5; $i++){
echo "<a href='".$domain."/index.php?action=play&ID=" . mysql_result($resultt, $i, "ID") . "'>" . mysql_result($resultt, $i, "Name") . " - (" . mysql_result($resultt, $i, "Views") . ")  </a>";}
echo '</div>';
                            echo '<br />';
                            echo '<a href=\''.$domain.'/index.php?action=mostplayed\' title=\'Most Played\'>View more >>></a>';}}

echo '</td></tr></table>';

It will add a new table to the the top: http://jamsiteproject.comli.com/ - Example of what it currently looks like

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Top 5 games
« Reply #5 on: October 15, 2011, 12:41:44 PM »
Latest games code fully working for the sidebars of the site. put this in template.php

Code: [Select]
<tr>
                 <td class="header2">Latest Games</td>
</tr>
<tr>
<td class="content2">                            
                   <?php
$queryl "SELECT Name, dateadded, ID FROM dd_games WHERE `active`='1' ORDER BY dateadded DESC";
$resultl mysql_query($queryl);
if (!$resultl) {
//do something if nothing is returned from the db
echo'An error occured';
}else{
if ($seo_on == 1){
echo '<ul class=\'catmenu\'>';
for ($i=0$i<5$i++){
echo "<li><a href='".$domain."/play/".mysql_result($resultl$i"ID")."-".mysql_result($resultl$i"Name").".html'>" mysql_result($resultl$i"Name") . "</a></li>";}
echo '</ul>';
                        echo 
'<br />';
                        echo 
'&nbsp;<a href=\''.$domain.'/newest/\' title=\'Most Played\'>View more >>></a>';
}else{
echo '<ul class=\'catmenu\'>';
for ($i=0$i<5$i++){
echo "<li><a href='".$domain."/index.php?action=play&ID=" mysql_result($resultl$i"ID") . "'>" mysql_result($resultl$i"Name") . "</a></li>";}
echo '</ul>';
                            echo 
'<br />';
                           
echo '&nbsp;<a href=\''.$domain.'/index.php?action=newest\' title=\'Newest\'>View more >>></a>';}}
?>

</td>
</tr>
« Last Edit: October 24, 2011, 09:45:11 PM by spagetiokillers »

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Top 5 games
« Reply #6 on: October 15, 2011, 12:45:49 PM »
Hi spagetiokiller I was wondering if you could help I have used your code on my site slightly changing it to fit in the centre rather than the sides but im not very good with php. My question is how do I add the image to the side of the game?

Below is how the code currently looks I would like to add it to the top of each title if possible?

http://jamsiteproject.comli.com/ - Example of what it currently looks like

Code: [Select]
echo '
      <table width=\'100%\' border=\'0\'>
      <tr>
      <td class=\'header\'>Top 5 Games</td>
</tr>

<tr>
<td class=\'content2\'>';

$minViews = 5;
$queryt = "SELECT Name, Views, ID FROM dd_games WHERE Views>$minViews ORDER BY Views DESC";
$resultt = mysql_query($queryt);
if (!$resultt) {
//do something if nothing is returned from the db
echo'An error occured';
}else{
if ($seo_on == 1){
echo '<div class=\'catmenu\'>';
for ($i=0; $i<5; $i++){
echo "<a href='".$domain."/play/".mysql_result($resultt, $i, "ID")."-".mysql_result($resultt, $i, "Name").".html'>" . mysql_result($resultt, $i, "Name") . " - (" . mysql_result($resultt, $i, "Views") . ")  </a>";}
echo '</div>';
                        echo '<br />';
                        echo '<a href=\''.$domain.'/mostplayed/\' title=\'Most Played\'>View more >>></a>';
}else{
echo '<div class=\'catmenu\'>';
for ($i=0; $i<5; $i++){
echo "<a href='".$domain."/index.php?action=play&ID=" . mysql_result($resultt, $i, "ID") . "'>" . mysql_result($resultt, $i, "Name") . " - (" . mysql_result($resultt, $i, "Views") . ")  </a>";}
echo '</div>';
                            echo '<br />';
                            echo '<a href=\''.$domain.'/index.php?action=mostplayed\' title=\'Most Played\'>View more >>></a>';}}

echo '</td></tr></table>';

Thanks for any help  ;D

Ill work on this when i get home

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Top 5 games
« Reply #7 on: October 24, 2011, 09:46:40 PM »
updated the script to include the check for if the game is active or not. Also added the 5 latest games to the first post. That way people dont have to scroll for it.

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: Top 5 games
« Reply #8 on: October 25, 2011, 10:39:09 PM »
Nice one! :)

Added something, but keep forgetting I'm not using the default script.

:(

Just a couple of small things. :)

Latest five has title=\'Most Played\' in it.  ;D

And if you ever want to validate your script and html, things like:

action=play&ID=" Should be -> action=play&amp;ID="

Else it wont validate.

;)

« Last Edit: October 26, 2011, 12:02:28 AM by mort »

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Top 5 games
« Reply #9 on: October 26, 2011, 02:11:48 PM »
LOL woops i didnt even notice the title in there.

Updated :)
« Last Edit: October 26, 2011, 02:21:31 PM by spagetiokillers »

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Top 5 games
« Reply #10 on: November 05, 2011, 08:11:52 PM »
Updated the code a lot i completely redid the way i called the sql query and the looping. I also fixed a few issues with links where it would sometimes break them depending on the games name. This update is very important if your using this.... of course unless your mort, then you probably already did this and DIDNT TELL ME! lol

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Top 5 games
« Reply #11 on: November 05, 2011, 11:22:47 PM »
Hi spagetiokiller I was wondering if you could help I have used your code on my site slightly changing it to fit in the centre rather than the sides but im not very good with php. My question is how do I add the image to the side of the game?

Below is how the code currently looks I would like to add it to the top of each title if possible?

http://jamsiteproject.comli.com/ - Example of what it currently looks like

Code: [Select]
echo '
      <table width=\'100%\' border=\'0\'>
      <tr>
      <td class=\'header\'>Top 5 Games</td>
</tr>

<tr>
<td class=\'content2\'>';

$minViews = 5;
$queryt = "SELECT Name, Views, ID FROM dd_games WHERE Views>$minViews ORDER BY Views DESC";
$resultt = mysql_query($queryt);
if (!$resultt) {
//do something if nothing is returned from the db
echo'An error occured';
}else{
if ($seo_on == 1){
echo '<div class=\'catmenu\'>';
for ($i=0; $i<5; $i++){
echo "<a href='".$domain."/play/".mysql_result($resultt, $i, "ID")."-".mysql_result($resultt, $i, "Name").".html'>" . mysql_result($resultt, $i, "Name") . " - (" . mysql_result($resultt, $i, "Views") . ")  </a>";}
echo '</div>';
                        echo '<br />';
                        echo '<a href=\''.$domain.'/mostplayed/\' title=\'Most Played\'>View more >>></a>';
}else{
echo '<div class=\'catmenu\'>';
for ($i=0; $i<5; $i++){
echo "<a href='".$domain."/index.php?action=play&ID=" . mysql_result($resultt, $i, "ID") . "'>" . mysql_result($resultt, $i, "Name") . " - (" . mysql_result($resultt, $i, "Views") . ")  </a>";}
echo '</div>';
                            echo '<br />';
                           echo '<a href=\''.$domain.'/index.php?action=mostplayed\' title=\'Most Played\'>View more >>></a>';}}

echo '</td></tr></table>';

Thanks for any help  ;D

Hey soul, Sorry it took so long..... i kinda forgot.... shoulda reminded me. But i have your mod you wanted :) i noticed you never did it so hopefully this will work for you!

Code: [Select]
$minViews = 0;
$count1 = 0;
$newest2 = "SELECT * FROM dd_games WHERE `active`='1' AND Views>$minViews ORDER BY Views DESC";
$newest1 = sqlcache('newest', $cachelife, $newest2);
echo'
<table width=\'100%\' border=\'0\'>
      <tr>
      <td class=\'header\'>Top 5 games</td>
      </tr>
      <tr>
      <td>';
      echo '<table width=\'100%\'>';
      foreach($newest1 as $row1 ){
if($count1<=4){
      $gamename = ereg_replace('[^A-Za-z0-9]', '-', $row1['name']);
      if($seo_on == 1){
      $playlink = ''.$domain.'/play/'.$row1['ID'].'-'.$gamename.'.html';
      }else{
      $playlink = ''.$domain.'/index.php?action=play&amp;ID='.$row1['ID'].'';
      }
      echo ' <tr>
      <td width=\'45\' height=\'45\' valign=\'top\' class=\'content\'>
      <a href=\''.$playlink.'\'>
      ';
      if($row1['type'] == 1){
      echo ' <img src=\''.$domain.'/'.$thumbsfolder.'/'.$row1['thumb'].'\' width=\'45\' height=\'45\' alt= \'\' border=\'0\'/>';
      }else{
      echo ' <img src=\''.$row1['thumburl'].'\' width=\'45\' height=\'45\' alt= \'\' border=\'0\'/>';
      }
     
      echo '
      </a>
      </td>
      <td valign=\'top\' class=\'content\'><div class=\'gamehometitle\'><a href=\''.$playlink.'\'>'.$row1['name'].'</a></div>
      <div class=\'gamehomedesc\'>'.desclimit($row1['description']).'
      <a href=\''.$playlink.'\'>Play</a></div></td>
      </tr>';
      }$count1++;};


echo '<tr><td colspan=\'2\' class=\'content\'>';      
if ($seo_on == 1){
echo '&nbsp;<a href=\''.$domain.'/mostplayed/\' title=\'Most Played\'>View more top games</a>';}else{
echo '&nbsp;<a href=\''.$domain.'/index.php?action=mostplayed\' title=\'Most Played\'>View more top games</a>';}
echo '</td>
</tr>
</table>';
« Last Edit: November 06, 2011, 12:04:04 AM by spagetiokillers »

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: Top 5 games
« Reply #12 on: November 05, 2011, 11:40:31 PM »
sql query, its not &&.. its just AND

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Top 5 games
« Reply #13 on: November 06, 2011, 12:02:31 AM »
sql query, its not &&.. its just AND

well then.... i guess ill fix that.... it seemed to work with && but if AND is proper ill do that.

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: Top 5 games
« Reply #14 on: November 06, 2011, 06:14:56 AM »
of course unless your mort, then you probably already did this and DIDNT TELL ME! lol

Hahaha! I did something different by adding "newest" to the header and removing it from the Nav Menu. So I've got 20 latest games. with Mouse-Over descriptions. :P