PhpDig.net

PhpDig.net (http://www.phpdig.net/forum/index.php)
-   Mod Submissions (http://www.phpdig.net/forum/forumdisplay.php?f=24)
-   -   Show number of indexed pages on homepage (http://www.phpdig.net/forum/showthread.php?t=306)

Freddie 12-18-2003 01:20 AM

show number of indexed pages on homepage
 
like google ;)

Freddie 12-18-2003 02:01 AM

I don't know much about php but... I got it :)


before head:

PHP Code:

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

and...

PHP Code:

$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 01:09 PM

He
 
Where this must be added?

Freddie 03-04-2004 02:28 PM

in the code of the page where you want to display the number of indexed pages

Slider 12-09-2004 08:31 AM

Show number of indexed pages on homepage
 
Code:

<?
$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 04: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 :)


All times are GMT -8. The time now is 12:02 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.