Jump to content

tjc19999

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tjc19999's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. PFMaBiSmAd, You are correct to assume that the $timearray contains elements in the form of YYYY-MM-DD format. I wanted to make sure that I only display data within a certain time range and it is also what I use to determine the select statement for each URL for each day. As you can assume the $urlarray contains elements like google.com, yahoo.com etc.
  2. I have a script to write out the number of hits each of my websites got each day of the week since I don't trust Google Analytics spying on my websites. The problem is that I have to query each day individually and count how many instances there are with that domain. Since I setup my database give me the time, location, demographics, etc. on each line I'm not sure how to optimize this further. Help would be greatly appreciated. echo '<table><tr><td>Domain</td>'; foreach($timearray as $t){ echo '<td>'.$t.'</td>'; } echo '</tr>'; $i = 0; foreach($urlarray as $u){ $today = date("Y-m-d"); $yesterday = date("Y-m-d", mktime(0,0,0,date("m") , date("d")-1, date("Y"))); $lastmonth = date("Y-m-d", mktime(0,0,0,date("m")-1 , date("d")-1, date("Y"))); $twoweeks = date("Y-m-d", mktime(0,0,0,date("m") , date("d")-15, date("Y"))); $result3 = mysql_query("SELECT refer,Count(*) as count FROM `approved` WHERE time>'$lastmonth 23:59:59' AND time<'$today' AND refer LIKE '%$u%'"); $row3 = mysql_fetch_array($result3); $result4 = mysql_query("SELECT refer,Count(*) as count FROM `approved` WHERE time>'$twoweeks 23:59:59' AND time<'$today' AND refer LIKE '%$u%'"); $row4 = mysql_fetch_array($result4); if($row3['count']==0){echo "<tr style='background:red'>";}elseif($row4['count']>0){echo "<tr style='background:green'>";}elseif($i % 2){echo "<tr style='background:#CCC'>";}else{echo "<tr style='background:#FFF'>";} echo '<td>'.$u.' '.$row3['count'].' '.$row4['count'].'</td>'; foreach($timearray as $t){ $result = ''; $result = mysql_query("SELECT COUNT(*) AS count FROM `approved` WHERE time LIKE '$t%' AND refer LIKE '%$u%'"); while($row = mysql_fetch_array($result)){ echo '<td>'.$row['count'].'</td>'; } } echo '</tr>'; $i++; } echo '</tr></table>';
  3. Hello experts, I am posting to get your opinion on how to get a certain result. Here is the scenario: I am currently collecting data on my websites to see how many page views I am getting for each site. Each website only consists of 1 page so I don't need to track sub pages or anything. So essentially I have a database with a list full of URLs going back several months. Now I would like to display the data in a table with the URLs in the first column and each column after that counting the number of visits obtained that day. Furthermore I would like to color code each row depending how long it has been since the last visit on my website. I have thought of several ways of going about beginning to code this project but was hoping to get some input from some more experienced PHP users before I begin. Sorry if this is posted in the wrong area. Thank you for your input.
  4. This is my final resolved code: while($z==0){ if($cityarrayalt[$z]!=""){ $curl_handle2=curl_init(); curl_setopt($curl_handle2,CURLOPT_URL,"http://www.searchbug.com/tools/zip-code-lookup.aspx?TYPE=city2zip&CITY=".preg_replace("/ /","+",$city[1][$z])."&STATE=".$state2); curl_setopt($curl_handle2, CURLOPT_RETURNTRANSFER, true); $sec = curl_exec($curl_handle2); curl_close($curl_handle2); preg_match("/<b>([0-9]{5})<\/b>/",$sec,$seczip); echo $seczip[1]; The issue is that the variable was $city[0][$z] but needed to be $city[1][$z] to grab only the text I wanted which was in the parentheses like my second preg_match...the hidden text was HTML tags which is why I could not SEE them. This problem has been resolved!
  5. The problem is this: urltest=array(3) { [0]=> string(21) "CAROL STREAM" [1]=> string(21) "CAROL STREAM" [2]=> string(21) "CAROL STREAM" } urltest2=array(3) { [0]=> string(12) "CAROL STREAM" [1]=> string(12) "CAROL STREAM" [2]=> string(12) "CAROL STREAM" } urltest array is the array that was genereated from a previous cURL and preg_match_all function that does not work urltest2 is a manually created array that works Can someone explain the difference between these seemingly identical arrays?
  6. I have the following SNIPPET of code: while($z==0){ if($cityarrayalt[$z]!=""){ $curl_handle2=curl_init(); curl_setopt($curl_handle2,CURLOPT_URL,"http://www.searchbug.com/tools/zip-code-lookup.aspx?TYPE=city2zip&CITY=".preg_replace("/ /","+",$city[0][$z])."&STATE=".$state2); curl_setopt($curl_handle2, CURLOPT_RETURNTRANSFER, true); $sec = curl_exec($curl_handle2); curl_close($curl_handle2); preg_match("/<b>([0-9]{5})<\/b>/",$sec,$seczip); echo $seczip[1]; $city[0][$z] is an array with values of cities in a given state I think the problem is that array $city is not being read as a string and cURL doesn't know how to interpret the value given. I tried entering a test string and it works, but there is something wrong with my array, see var_dump below: array(2) { [0]=> array(47) { [0]=> string(21) "CAROL STREAM" [1]=> string(21) "CAROL STREAM" [2]=> string(21) "CAROL STREAM" [3]=> string(21) "CAROL STREAM" [4]=> string(21) "CAROL STREAM" [5]=> string(21) "CAROL STREAM" [6]=> string(21) "CAROL STREAM" [7]=> string(25) "GLENDALE HEIGHTS" [8]=> string(21) "BLOOMINGDALE" [9]=> string(21) "BLOOMINGDALE" [10]=> string(16) "WHEATON" [11]=> string(17) "WINFIELD" [12]=> string(19) "GLEN ELLYN" [13]=> string(16) "ROSELLE" [14]=> string(19) "GLEN ELLYN" [15]=> string(16) "MEDINAH" [16]=> string(16) "WHEATON" [17]=> string(16) "ADDISON" [18]=> string(21) "HANOVER PARK" [19]=> string(21) "WEST CHICAGO" [20]=> string(16) "LOMBARD" [21]=> string(15) "ITASCA" [22]=> string(21) "WEST CHICAGO" [23]=> string(17) "BARTLETT" [24]=> string(19) "SCHAUMBURG" [25]=> string(19) "VILLA PARK" [26]=> string(18) "WOOD DALE" [27]=> string(19) "SCHAUMBURG" [28]=> string(19) "SCHAUMBURG" [29]=> string(20) "WARRENVILLE" [30]=> string(14) "WAYNE" [31]=> string(19) "STREAMWOOD" [32]=> string(19) "SCHAUMBURG" [33]=> string(17) "ELMHURST" [34]=> string(26) "ELK GROVE VILLAGE" [35]=> string(20) "BENSENVILLE" [36]=> string(14) "LISLE" [37]=> string(20) "BENSENVILLE" [38]=> string(22) "DOWNERS GROVE" [39]=> string(18) "WOOD DALE" [40]=> string(24) "HOFFMAN ESTATES" [41]=> string(18) "OAK BROOK" [42]=> string(19) "NAPERVILLE" [43]=> string(26) "ELK GROVE VILLAGE" [44]=> string(17) "HINSDALE" [45]=> string(19) "SCHAUMBURG" [46]=> string(19) "SCHAUMBURG" } [1]=> array(47) { [0]=> string(12) "CAROL STREAM" [1]=> string(12) "CAROL STREAM" [2]=> string(12) "CAROL STREAM" [3]=> string(12) "CAROL STREAM" [4]=> string(12) "CAROL STREAM" [5]=> string(12) "CAROL STREAM" [6]=> string(12) "CAROL STREAM" [7]=> string(16) "GLENDALE HEIGHTS" [8]=> string(12) "BLOOMINGDALE" [9]=> string(12) "BLOOMINGDALE" [10]=> string(7) "WHEATON" [11]=> string( "WINFIELD" [12]=> string(10) "GLEN ELLYN" [13]=> string(7) "ROSELLE" [14]=> string(10) "GLEN ELLYN" [15]=> string(7) "MEDINAH" [16]=> string(7) "WHEATON" [17]=> string(7) "ADDISON" [18]=> string(12) "HANOVER PARK" [19]=> string(12) "WEST CHICAGO" [20]=> string(7) "LOMBARD" [21]=> string(6) "ITASCA" [22]=> string(12) "WEST CHICAGO" [23]=> string( "BARTLETT" [24]=> string(10) "SCHAUMBURG" [25]=> string(10) "VILLA PARK" [26]=> string(9) "WOOD DALE" [27]=> string(10) "SCHAUMBURG" [28]=> string(10) "SCHAUMBURG" [29]=> string(11) "WARRENVILLE" [30]=> string(5) "WAYNE" [31]=> string(10) "STREAMWOOD" [32]=> string(10) "SCHAUMBURG" [33]=> string( "ELMHURST" [34]=> string(17) "ELK GROVE VILLAGE" [35]=> string(11) "BENSENVILLE" [36]=> string(5) "LISLE" [37]=> string(11) "BENSENVILLE" [38]=> string(13) "DOWNERS GROVE" [39]=> string(9) "WOOD DALE" [40]=> string(15) "HOFFMAN ESTATES" [41]=> string(9) "OAK BROOK" [42]=> string(10) "NAPERVILLE" [43]=> string(17) "ELK GROVE VILLAGE" [44]=> string( "HINSDALE" [45]=> string(10) "SCHAUMBURG" [46]=> string(10) "SCHAUMBURG" } } Can anyone help out with this?
  7. Basically if I have the number 1234 I do not want to have anything like 1334 OR 2234, OR 1235 but if i have 1245 it is fine. Here is what I currently have 0000-0099,1100-1199, 2200-2299 etc. I'm not sure if I can add any other numbers otherwise there will be more than 2 numbers in the same place in common. Does that make sense?
  8. I need a way to find numbers 0000-9999 where no number has more than 2 digits in the same place in common. I know PHP but this is a little beyond me, can anyone help?
  9. That most certainly did the trick...a bit more complex than anything I have come across as of yet. Thank you very much...you have ended a long day of hitting my head against the desk.
  10. Hello everyone, I need some help figuring out the proper subquery for my select statement. Here are 2 codes that I have: $result = mysql_query("SELECT * FROM applications WHERE history=(select MAX(history) FROM applications)"); $result = mysql_query("SELECT DISTINCT id FROM applications"); Both of these queries work, but what I need is a subquery that will 1) select DISTINCT id 2) for each distinct ID select max(history) Thank you in advance if you can help.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.