View Full Version : How do i pull data from the database into other pages?
Hi!
I don't know how to do this with vb - i just want to pull data from the vb-database into other html-pages (SSI?):
First i want to show the newest membername
Additionally I want to show the stats like x threads, x posts and x members
Could anyone post this here?
Thanks for help!
you could do that with PERL is you're wanting to pull it in as an SSI call.
You have to set some base information as variables up in the SSI call, like your DB info (host, dbname, username, pass) and set your connection query and then write a little script to tell it what you want to pull and how you want it to display.
Not tough stuff:D
Hmm ... could you post an example? ;)
Realize that all of these won't apply here?
These are excerpts I wrote for an SSI call pulling featured and hot items from a mySQL Auction Site I'm about to finish:
The DB stuff:
_____________________________________
#!/usr/bin/perl
use CGI qw(:standard);
use Mysql;
#------------------[ Program Configuration
$deger = new CGI;
$currency = "\$"; # Currency Symbol (If you use USD, then include \ char.
$delimeter = "?"; # Don't change this value
$mysql_host = "your host";
$mysql_dbname = "your db name";
$mysql_username = "your username";
$mysql_password = "your password";
$dbh = Mysql->connect("$mysql_host","$mysql_dbname","$mysql_username","$mysql_password") || error('connect');
______________________________________________
Note that the DB Call uses mySQl. DBI is not set up on this particular server. It's also set as a variable to save a lot of typing later in the script:)
______________________________________________
This is the sub used to call hot items. It will show you how to set up the database calls:
______________________________________________
sub hotitem
{
my ($sdh);
if ($cat ne "all")
{
$sdh = $dbh->query("SELECT * FROM tblItems WHERE itCategory LIKE '%$cat%'");
}
elsif ($cat eq "all")
{
$sdh = $dbh->query("SELECT * FROM tblItems");
}
(my $total_found) = $sdh->numrows;
if ($total_found ne "0")
{
my $sayac2 = 1;
for my $sayac(1..$total_found)
{
(my @content) = $sdh->fetchrow();
my $sdh2 = $dbh->query("SELECT * FROM tblBids WHERE biItem='@content[0]'");
(my $bid_total) = $sdh2->numrows;
if ($bid_total >= $bid)
{
@keeper[$sayac2-1] = join("$delimeter",@content);
$sayac2++;
}
}
}
$total_found = @keeper;
if ($total_found < $num)
{
$num = $total_found;
}
for my $sayac(1..$num)
{
my $flag = 0;
my $random = int(rand($total_found));
foreach my $keeper2(@keeper2)
{
if ($keeper2 eq $random)
{
$flag = 1;
last;
}
}
if ($flag eq "0") { push (@keeper2,$random); }
}
open (HTML,"$template_file");
my @html = <HTML>;
close(HTML);
my $global_line = join('',@html);
$global_line =~ s/_list_type_/Hot Items/g;
$global_line =~ s/<list>([\w\W]*)<\/list>/&list_html($1)/ie;
&header;
print $global_line;
exit;
}
__________________________________________________ _
see how the $dbh variable is used to set up the query?
Granted, this is for a specialized proggie, but the basics are all in there:D
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.