Nuke Statistics to HTML



This tutorial is to help those who have searched so long to find a way to include php nuke statistics (number of member, total hits, forum posts, downloads and much more) into a html document. It is actually quite easy once you have a basic knowledge of php and html but fear not, this tutorial is also for people with little or no knowledge of php, html and MySql.

:: Tutorial ::
Create a blank php file, this can easily be done in Dreamweaver from the File>New menu. Insert your php tag ( <?php ) then the first thing to add is ( require_once("mainfile.php"); ). This has your database log-in info so instead of writing your user name and passwords, you just include that file. Next it's time to start adding the stats you need, for this tutorial I will use the page hits. To gather that information you need to query the tables in your database. We do that by using this query .....

$sql = "SELECT count FROM ".$prefix."_counter WHERE type='total' AND var='hits'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $pageview = "Total Hitz $row[0] "; 

Next we need to echo the result, we do that by adding this last bit of code.

echo "<left><font color=\"FF0000\" size=\"9\"><b>$pageview</b></font><br>";

Close your php tag.. ?>. Your php file should look like the following.

<?php
require_once("mainfile.php");
$sql = "SELECT count FROM ".$prefix."_counter WHERE type='total' AND var='hits'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $pageview = "Total Hitz $row[0] "; 
echo "<left><font color=\"FF0000\" size=\"9\"><b>$pageview</b></font><br>";
?>

Save the php page to your nuke root directory, this is the same folder as your config.php and mainfile.php. The final step is to include the file in your html page. Open your html file and use a php include like the following.

<? include("http://yoursite.com/nuke/name of your php file"); ?>

That's it, you are all done. If you need further help please post inside our forums.