Forum Moderators: coopster
I am very new here, and have been debating whether to post this or not.
I own a small website that tries to index all the www and display search queries based on a selection of keywords. So our crawler visits the web (the whole web) and based on certain keywords it decides to index a page or not.
Now, our users can then use this search engine to search for any string and get results that have been pre-filtered.
1) I want to grab a number that shows the total size of the index, using this querie
SELECT COUNT(*), SUM(docsize) FROM url WHERE status IN (200,206,304,2200,2206,2304);
So I want to display the result on the website
2) I want to display the most searched for words using this query
SELECT qwords,count(*),sum(found),avg(found) FROM qtrack GROUP BY qwords;
Again, showing the result, but only the top 10
Can someone help,
Mike
1) I want to grab a number that shows the total size of the index, using this querie
$sql="SELECT COUNT(*) as c, SUM(docsize) as s FROM url WHERE status IN (200,206,304,2200,2206,2304)";
$result=mysql_query($sql) or die(mysql_error());
$record=mysql_fetch_assoc($result);
$yourSum=$record["s"];
$yourCount=$record["c"];
echo "Count: $yourCount <br>Sum: $yourSum";
2) I want to display the most searched for words using this query
$sql="SELECT qwords,count(*) as c,sum(found) as s,avg(found) as a FROM qtrack GROUP BY qwords limit 10";
$result=mysql_query($sql) or die(mysql_error());
while($record=mysql_fetch_assoc($result))
{
$avg=$record["a"];
$sum=$record["s"];
$total=$record["count"];
$qwords=$record["qwords"];
//then your echo statements here
}
notice the "LIMIT 10" in second query