Buying Fix small script

Discussion in 'Programming' started by WeX09, Apr 13, 2011.

  1. #1
    I have the following query to pull out information from the table visitors.

    $query = ("SELECT referer, browser_ip, date, customers_id, counter, browser_id, browser_language FROM visitors WHERE SUBSTRING(browser_language,1,1) != '[' ORDER by date DESC");

    Where referer is $_SERVER[HTTP_REFERER] and browser_ip is the visitors ip.

    I need to create two reports:

    1- Extract from referer the keywords, group, sort, count and display alphabetically giving the count for each keyword. A delete button beside each keyword will delete the complete count of the particular keyword from table visitors.

    2-I use the following code:

    include("geoipcity.inc");
    $gi = geoip_open('GeoLiteCity.dat',GEOIP_STANDARD);
    $ut= $row[1];
    $record = geoip_record_by_addr($gi, $ut);

    To pull out the following data:

    $record->country_name
    $record->region
    $record->city

    Again, I need to group, sort, count and display based on country and region in another page report.


    So far, the part of code I have is the one attached. It is working without errors, but does not produce what I need.

    Let me know if you have questions. Payment via paypal.

    Thanks


    include("geoipcity.inc");
    $gi = geoip_open('GeoLiteCity.dat',GEOIP_STANDARD);
    
    $query = ("SELECT referer, browser_ip, date, customers_id, counter, browser_id, browser_language FROM visitors WHERE SUBSTRING(browser_language,1,1) != '[' ORDER by date DESC");
    $result = mysql_query($query) or die(mysql_error());
    while ($row = mysql_fetch_array($result)) {
    
    //-----------------------------------------------------GEOIP VISITOR LOCATION
    $ut= $row[1];
    $record = geoip_record_by_addr($gi, $ut);
    
    $referer = $row[0];
    IF($referer)
    {
        PREG_MATCH("/[\&\?]q=([^&]*)/", $referer, $matches);
            $search_query = RAWURLDECODE($matches[1]);
            $search_query = STR_REPLACE("+", " ", $search_query);
    }
    
    //-----------------------------------------------------
    
    if ($search_query)
    	{
    	echo
    	"<tr>" . 
    	"<td width='50%' align='left' valign='top' class='main'><b>" . $search_query . " <font color='red' size='2'> " . "</font></B><br>" . "</a></td>" .
    	"<td width='25%' align='left' valign='top'>" . $record->country_name . " " . $record->region . " (" . $record->area_code . ")<br>" . $record->city . "</td>" .
    	"<td width='15%' align='left' valign='top'>" . $row[1] . "</td>" .
    	"<td width='20%' align='left' valign='top'>" . tep_date_short($row[2]) . "<br>" . "</td>" .
    	"<td width='7%' align='left' valign='top'># " . $row[5] ."</td></tr>";
     }
    PHP:
     
    WeX09, Apr 13, 2011 IP
  2. HowDoYou

    HowDoYou Well-Known Member

    Messages:
    443
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    130
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    you need to completely rethink your code...
    also, whats in geoipcity?
     
    HowDoYou, Apr 13, 2011 IP