Helpful Information
 
 
Category: vB3 General Discussions
Including VB elements into external page, best way to do it ?

I will include these vb elements into my site's main page:

-Number of users
-Currently online (just number, not the name)
-Guests currently online
-Total messages
-Last registered member.

How do you do this ? Do you create separate php file for each of these elements and then include them in your php page ?

Of do you set a global value for them all and them include the all the codes right in your page ?

Do you know good threads here that will tell me how to include all these elements ?

Even if all these existing integration 1.x codes will work with 2.0 (as stated) will there be different more efficient way to do it with 2.0 ?

Thanks,

i just put each of the codes in a .php.inc file and then included them on the page. but included global.php on the page i wanted the info to appear so it wouldnt need to be included in all the .php.inc files.

Ok thanks.
Can you tell me here exactly the line you put in your main file to call the global php that will be used for all the little files to include ?

Thanks,

Yes, im really interested in the same think.

me too

put this code before the <html> tag.
<?php include("/direct/path/to/global.php") ?>

Here is the hack for showing the top posters on a page, im positive it can be edtited to show other things, I'll do that later :D , but for now its only top 10 posters: :p


<?php
require("path/to/global.php");

print("<table><tr><td colspan=\"2\">Top Posters</td></tr>
<tr><td><b>Username</b></td><td><b>Posts</b></td></tr>");

$db_link = @mysql_pconnect("$dbservername", "$dbusername", "$dbpassword");
mysql_select_db ("$dbname", $db_link);

$query = mysql_query("SELECT posts, username FROM user ORDER BY user.posts DESC, user.username DESC LIMIT 0, 10");

while($row = mysql_fetch_array($query))
{
$username = $row["username"];
$posts = $row["posts"];

print("<tr><td>$username</td><td>$posts</td></tr>");
}

print("</table>");

?>

You need to rename the page from .HTML (or whatever you have it as) to .PHP or this wont work! If you have SSI elements they may not work in .PHP pages (depending on how you have them set up) so you will need the script im posting later here to fix that.

snyx

http://www.vbulletin.com/forum/showthread.php?s=&threadid=8017










privacy (GDPR)