Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Problem with including a PHP script [SOLVED] (http://www.mysidiaadoptables.com/forum/showthread.php?t=389)

alus1onZ 02-15-2009 01:10 PM

Problem with including a PHP script [SOLVED]
 
With my noobish php knowledge I've made a script that extract information from the mysql db and display it as a top 100 ranking of the adoptables. But the problem is I don't know how to replace the get content function in extrapage.php:

PHP Code:

$query "SELECT * FROM article_content WHERE page = 'extra'";
$result mysql_query($query);
$num mysql_numrows($result); 

With mine php top 100 script :(

Please if someone can tell me how to replace it I will be very thankful

Here it's the php Top 100 adoptables script, feel free to use it on your page if you want. It may have issues but as I say my knowledge in php is very poor. :)

PHP Code:

<?php
{
  
$getscores="SELECT totalclicks,name,currentlevel,owner,type from owned_adoptables order by totalclicks DESC limit 100";
  
$getscores2=mysql_query($getscores) or die("Could not get scores");
  
$rank=1;
  echo 
"<center><h3>Top 100 adoptables</h3></center><center>";
  echo 
"<table width=50%><tr><th>Position</th><th>Name</th><th>Clicks</th><th>Level</th><th>Owner</th><th>Type</th></tr>";
  while(
$getscores3=mysql_fetch_array($getscores2))
  {
     
$getscores3[name]=strip_tags($getscores3[name]);
     echo 
"<tr><td>$rank</td><td>$getscores3[name]</td><td>$getscores3[totalclicks]</td><td>$getscores3[currentlevel]</td><td>$getscores3[owner]</td><td>$getscores3[type]</td></tr>";
     
$rank++;
  }
  echo 
"</table></center><br><br>";
}
?>

[hr]
OK, I got it! :D

The easiest way is to add a div class style in the main.css then in extrapage.php place this before the top 100 code
Code:

echo "<div class=\"your div class"\>";
and after the top 100 code put this
Code:

echo "</div>";
so your php code will look something like this:

PHP Code:

  echo "<div class=\"top100\">";
{
  
$getscores="SELECT totalclicks,name,currentlevel,owner,type from owned_adoptables order by totalclicks DESC limit 100";
  
$getscores2=mysql_query($getscores) or die("Could not get scores");
  
$rank=1;
  echo 
"<center><h3>Top 100 adoptables</h3></center><center>";
  echo 
"<table width=50%><tr><th>Position</th><th>Name</th><th>Clicks</th><th>Level</th><th>Owner</th><th>Type</th></tr>";
  while(
$getscores3=mysql_fetch_array($getscores2))
  {
     
$getscores3[name]=strip_tags($getscores3[name]);
     echo 
"<tr><td>$rank</td><td>$getscores3[name]</td><td>$getscores3[totalclicks]</td><td>$getscores3[currentlevel]</td><td>$getscores3[owner]</td><td>$getscores3[type]</td></tr>";
     
$rank++;
  }
  echo 
"</table></center><br><br>";
}
  echo 
"</div>"

Best wishes, alus1onZ :P

BMR777 02-15-2009 05:07 PM

RE: Problem with including a PHP script [SOLVED]
 
Glad you got it sorted. :)

alus1onZ 02-15-2009 07:02 PM

RE: Problem with including a PHP script [SOLVED]
 
Feel free to use it for further updates of the script, it will be nice to people have a top 100 module in their sites :)


All times are GMT -5. The time now is 03:04 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.