ziedinjsh Posted October 4, 2012 Report Share Posted October 4, 2012 (edited) Sveiki! ir tāda lieta ka dtubāzē tiek saglabātās šādas lietas: ip, url, domain. pie izvadīšanas ar while protams viss ir pēc kārtās. Jautājums ir sekojoš: Kā var izvadīt tā lai parādas piem tikai domain ar count cik ir saistīts ar šo domēnu zem kura ir atkal dažādi url kuriem ir šis domēns un pie šī url ir atkal count ja ir identiski url. Piemēram: www.google.lv (3): www.facebook.com?page=4 (x1); www.facebook.com?page=7 (x5); www.kkas.lv?id=3 (x1) www.facebook.com (2): www.google.com?search=lapa (x1) www.google.com?search=savaadaak (x4) Edited October 4, 2012 by ziedinjsh Quote Link to comment Share on other sites More sharing options...
codez Posted October 4, 2012 Report Share Posted October 4, 2012 (edited) uztaisi tabulu urls, kurā ir lauki: url, count, kur katram unikālam url-am skaita skaitu. Un katru reizi, kad liec klāt urlu ip tabulā, papildi arī urls tabulu. Edited October 4, 2012 by codez Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 4, 2012 Author Report Share Posted October 4, 2012 Paldies par ideju, bet uzmocīju šādi: $hvz = mysql_query("select domain, count(1) as rpt_count from referer group by domain"); while($data = mysql_fetch_array($hvz)){ echo '<p>'.$data['domain'].'('.$data['rpt_count'].')</p>'; $d = mysql_query("select url, count(1) as rp_count from referer where domain='".$data['domain']."' group by url") or die(mysql_error()); while($data = mysql_fetch_array($d)){ echo '<p style="font-size:12px;color:#ccc;">'.$data['url'].' ('.$data['rp_count'].')</p>'; } } Quote Link to comment Share on other sites More sharing options...
Kemito Posted October 4, 2012 Report Share Posted October 4, 2012 $hvz = mysql_query("select domain, count(1) as rpt_count from referer group by domain"); Gadījumā vēlams nebija rakstīt $hvz = mysql_query("SELECT domain, count(1) AS rpt_count FROM referer GROUP by domain"); ? Kapēc vispār ir jātaisa "echo" ar "HTML" saturu? Noderētu palasīt - "MVC" Quote Link to comment Share on other sites More sharing options...
aaxc Posted October 4, 2012 Report Share Posted October 4, 2012 (edited) Vēl kas, mysql_* komandu vietā sākam izmantot mysqli_query() vai PDO::query(), lai vēlāk nerastos problēmas. Edited October 4, 2012 by aaxc Quote Link to comment Share on other sites More sharing options...
codez Posted October 4, 2012 Report Share Posted October 4, 2012 Tu saproti, kas notiks, ja tev būs 100 urļi, kur katram būs, piemēram, vidēji 10`000 skaits? Mysql ies cauri 1M rindu un tāpēc jārēķinās ar performanci. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.