PDA

View Full Version : Show number of indexed pages on homepage


Freddie
12-18-2003, 02:20 AM
like google ;)

Freddie
12-18-2003, 03:01 AM
I don't know much about php but... I got it :)


before head:

$relative_script_path = '..';
include "$relative_script_path/includes/config.php";

and...

$phpdig_tables = array('sites'=>'Hosts','spider'=>'Pages');

while (list($table,$name) = each($phpdig_tables))
{
$result = mysql_fetch_array(mysql_query("SELECT count(*) as num FROM ".PHPDIG_DB_PREFIX."$table"),MYSQL_ASSOC);
print "<tr>\n\t<td class=\"greyFormLight\">\n$name : </td>\n\t<td class=\"greyForm\">\n<b>".$result['num']."</b></td>\n</tr>\n";
}

print "</table>\n";

TiM
03-04-2004, 02:09 PM
Where this must be added?

Freddie
03-04-2004, 03:28 PM
in the code of the page where you want to display the number of indexed pages

Slider
12-09-2004, 09:31 AM
<?
$db=mysql_connect('host','db_user','db_pass');
mysql_select_db("database_name");
$query = "SELECT * FROM spider";
$results = mysql_query($query);
$num_results = mysql_num_rows($results);
?>


Searching <?echo $num_results?> web pages

I did find and old post with the same title but the code wouldn't work so I made this. I was not able to post to the old post , so here is a working version.

BulForce
01-18-2005, 05:36 PM
Before the </head> tag add this lines:

<?php
$relative_script_path = '/home/virtual/site15/fst/var/www/search';
include "$relative_script_path/includes/config.php";
?>

change "/home/virtual/site10/fst/var/www/search" with your full script path

then at the place where you want to display the pages add this code:

<?php
$phpdig_tables = array('spider'=>'Currently indexed');

while (list($table,$name) = each($phpdig_tables))
{
$result = mysql_fetch_array(mysql_query("SELECT count(*) as num FROM ".PHPDIG_DB_PREFIX."$table"),MYSQL_ASSOC);
print "$name ".$result['num']." pages";
}
?>

And in the place where you want to display the hosts add this code:

<?php
$phpdig_tables = array('sites'=>'At');

while (list($table,$name) = each($phpdig_tables))
{
$result = mysql_fetch_array(mysql_query("SELECT count(*) as num FROM ".PHPDIG_DB_PREFIX."$table"),MYSQL_ASSOC);
print "$name ".$result['num']." hosts";
}
?>

Thas all :)