PDA

View Full Version : Problem with including a PHP script [SOLVED]


alus1onZ
02-15-2009, 01:10 PM
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:

$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
{
$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 echo "<div class=\"your div class"\>"; and after the top 100 code put this echo "</div>"; so your php code will look something like this:

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
Glad you got it sorted. :)

alus1onZ
02-15-2009, 07:02 PM
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 :)