Pentiums Posted March 4, 2009 Report Share Posted March 4, 2009 (edited) Sveiki, man ir while cikls, kas izvada meklēšanas frāzes ar ko ieiets lapā no googles, bet tas tā... Negribu izvadīt vienādas frāzes, bet gan izvadīt tikai vienu no vienādajām un galā pierakstīt skaitu cik tad ir, piemēram: Anekdotes par seksu 5 Anekdotes zaķītis 2 Lamuvārdi 2 Windows vista instalācija .. ...... utt.. Te mans murgs: $result = mysql_query("SELECT * FROM hits WHERE referer LIKE '%google%' AND referer LIKE '%search%' AND referer LIKE '%q=%' ORDER BY hit_id DESC") or die(mysql_error()); while($data = mysql_fetch_array($result)) { $referer = substr($data['referer'], 7); list($domain, $address) = explode('/', $referer); list($shitt, $phrasee) = explode('q=', $address); list($phrase, $shit) = explode('&', $phrasee); echo '<tr> <td>'.htmlspecialchars(urldecode(str_replace('+', ' ', $phrase))).'</td> </tr>'; } Edited March 4, 2009 by Pentiums Quote Link to comment Share on other sites More sharing options...
martins256 Posted March 4, 2009 Report Share Posted March 4, 2009 Pamēģini šādi. "SELECT hits.*,COUNT(*) as count FROM hits WHERE referer LIKE '%google%' AND referer LIKE '%search%' AND referer LIKE '%q=%' GROUP BY referer ORDER BY hit_id DESC" Quote Link to comment Share on other sites More sharing options...
Pentiums Posted March 4, 2009 Author Report Share Posted March 4, 2009 (edited) tas taču papildus izvadīs tikai skaitu cik reizes ir meklēts googlē kopā EDIT: Kļūdījos, bet GROUP BY arī neder, jo refferer nav vienādi, viņam tak galā tiek piekabināti visādi pārlūka shiti, piemēram atslēgvārdi ir vienādi, bet... http://www.google.lv/search?hl=lv&q=web+kameras&btnG=Google+mekl%C4%93%C5%A1ana&meta=&aq=f&oq= http://www.google.lv/search?q=web+kameras&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a Edited March 4, 2009 by Pentiums Quote Link to comment Share on other sites More sharing options...
martins256 Posted March 4, 2009 Report Share Posted March 4, 2009 http://lv.php.net/function.array-unique Quote Link to comment Share on other sites More sharing options...
marcis Posted March 4, 2009 Report Share Posted March 4, 2009 ... $data=array(); while(...){ $q=... if(!array_key_exists($q,$data)){ $data[$q]=1; continue; } ++$data[$q]; } foreach($data as $q=>$c){ echo $q,' ',$c,'<br />'; } Quote Link to comment Share on other sites More sharing options...
Paulinjsh Posted March 5, 2009 Report Share Posted March 5, 2009 Nu tad tad, kad pieglabā refereri novāc "browsera šitus" vai arī http://dev.mysql.com/doc/refman/5.0/en/string-functions.htm SELECT ... LEFT(RIGHT(referer, LOCATE('q=', referer)), LOCATE('&', LOCATE('q=', referer))); as q ... nez vai strādā un baigi samuģīti Quote Link to comment Share on other sites More sharing options...
Pentiums Posted March 5, 2009 Author Report Share Posted March 5, 2009 Jau izfiltrēju meklēšanas atslēgvārdus pie ievietošanas DB un atsevišķā laukā `keywords` ievietoju atslēgvārdus un izvadīju ar GROUP BY :) 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.