Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php] Przeszukiwarka
mate
post 3.07.2007, 22:13:14
Post #1





Grupa: Zarejestrowani
Postów: 50
Pomógł: 0
Dołączył: 27.06.2007

Ostrzeżenie: (0%)
-----


Witam!
Mam taki kod przeszukiwarki artykułów:
  1. <?php
  2.  
  3.  $sql = "select * from search_terms where term = '$searchingred'";
  4.  
  5.  $result = mysql_query($sql ,$db);
  6.  
  7.  if (mysql_num_rows($result) > 0) {
  8.  
  9. $row = mysql_fetch_row($result);
  10. $count = $row[1];
  11. $newcount = $count + 1;
  12. $sql = "update search_terms set count = $newcount where term = '$searchingred'";
  13.  
  14.  } else {
  15.  
  16. $sql = "insert into search_terms (term, count) values ('$searchingred', 1)";
  17.  
  18.  }
  19.  
  20.  $result = mysql_query($sql ,$db);
  21.  
  22. ?>


Problem jest w tym, ze zamiast szukac po tematach szuka w zawartosci artykulow. Co zmienic, aby po wpisaniu slowa kluczowego w wyszukiwarce znajdowalo tytuly artow, a nie ich zawartosc?
Pozdrawiam!
Go to the top of the page
+Quote Post
Daimos
post 3.07.2007, 22:25:16
Post #2





Grupa: Zarejestrowani
Postów: 1 319
Pomógł: 118
Dołączył: 26.11.2003
Skąd: Lublin

Ostrzeżenie: (0%)
-----


zamien kolumne term na odpowiednia, w ktorej sa tytuly artow


--------------------
scriptun.com. Startup z poradnikami do gier ttp.zone i ttpzone.pl
Go to the top of the page
+Quote Post
mate
post 14.07.2007, 09:02:33
Post #3





Grupa: Zarejestrowani
Postów: 50
Pomógł: 0
Dołączył: 27.06.2007

Ostrzeżenie: (0%)
-----


Cytat(my salsa @ 3.07.2007, 23:25:16 ) *
zamien kolumne term na odpowiednia, w ktorej sa tytuly artow


Czyli co? Pozmienialem wszedzie gdzie pisalo term na title, ale i tak dalej wyszukuje tak samo. Mozesz mi troche jasniej powiedziec co i jak?
Wybacz mi moja niekumatosc.. sadsmiley02.gif

pomoze ktos??

da sie cos z tym zrobic? :/ Prosze o pomoc! to bardzo wazne, a sam rady nie umie juz dac w tej kwestii :/
Go to the top of the page
+Quote Post
delfinium
post 14.07.2007, 10:06:13
Post #4





Grupa: Zarejestrowani
Postów: 90
Pomógł: 6
Dołączył: 30.06.2007
Skąd: Zielona Góra

Ostrzeżenie: (0%)
-----


Mistrzu ale ten kod nie przeszukuje artykułów tylko uaktualnia statystyki przeszukiwań względem szukanej frazy. Jeśli taka fraza była już szukana to zwiększa licznik o 1 a jeśli po raz pierwszy to dodawany jest nowy rekord. Gdzie tu masz przeszukiwanie artykułów?
Go to the top of the page
+Quote Post
mate
post 14.07.2007, 11:20:17
Post #5





Grupa: Zarejestrowani
Postów: 50
Pomógł: 0
Dołączył: 27.06.2007

Ostrzeżenie: (0%)
-----


Cytat(delfinium @ 14.07.2007, 11:06:13 ) *
Mistrzu ale ten kod nie przeszukuje artykułów tylko uaktualnia statystyki przeszukiwań względem szukanej frazy. Jeśli taka fraza była już szukana to zwiększa licznik o 1 a jeśli po raz pierwszy to dodawany jest nowy rekord. Gdzie tu masz przeszukiwanie artykułów?

to musialo mi sie cos pomylic :/

Macie caly skrypt biggrin.gif moze sie da cos zrobic? snitch.gif

  1. <?php
  2.  
  3.  $sql = "select * from search_terms where term = '$searchingred'";
  4.  
  5.  $result = mysql_query($sql ,$db);
  6.  
  7.  if (mysql_num_rows($result) > 0) {
  8.  
  9. $row = mysql_fetch_row($result);
  10. $count = $row[1];
  11. $newcount = $count + 1;
  12. $sql = "update search_terms set count = $newcount where term = '$searchingred'";
  13.  
  14.  } else {
  15.  
  16. $sql = "insert into search_terms (term, count) values ('$searchingred', 1)";
  17.  
  18.  }
  19.  
  20.  $result = mysql_query($sql ,$db);
  21.  
  22. ?>
  23.  
  24. <TD align="left" valign="top" bgcolor="#DEDDDC">
  25. <table width="100%" border="0" cellspacing="5" cellpadding="5">
  26. <tr>
  27. <td valign="top">
  28. <TABLE width=100% cellpadding=5 cellspacing=0 border=0>
  29.  
  30. <tr><td width=500 align=center>
  31.  
  32.  <table cellpadding=1 cellspacing=1 border=0><tr><td bgcolor=#000000 width=500 height=20 valign=center align=center>
  33. <table cellpadding=0 cellspacing=0 border=0><tr><td bgcolor=#cccccc width=498 height=18 valign=center align=left>
  34.  <font face="Arial, Helvetica, sans-serif" size="3"><b>Wyniki</b></font>
  35.  </td></tr></table>
  36.  </td></tr></table>
  37.  
  38. </td></tr>
  39.  
  40. <TR>
  41. <TD valign=top>
  42.  
  43. <p><center><FONT face="Arial, Helvetica, sans-serif" size=2>Wszystkie tipsy zawierające słowo '</font><FONT face="Arial, Helvetica, sans-serif" size=2 color=red><?php printf($searchingred); ?></font><FONT face="Arial, Helvetica, sans-serif" size=2>'</center></p>
  44.  
  45. <table cellspacing=0 cellpadding=2 border=0>
  46.  <tr>
  47. <th width=300 bgcolor=#bbbbbb align=center><FONT face=arial size=2>Nazwa</font></th>
  48. <th width=85 bgcolor=#bbbbbb align=center><FONT face=arial size=2>Data dodania</font></th>
  49. <th width=75 bgcolor=#bbbbbb align=center><FONT face=arial size=2>Ocena</font></th>
  50.  </tr>
  51.  
  52.  <?php
  53.  
  54. $sql = "select tipid from tips where tip like '% $searchingred %' and status = 'L'";
  55.  
  56. $result = mysql_query($sql ,$db);
  57.  
  58. $tipcount = 0;
  59.  
  60. if ($myrow = mysql_fetch_array($result)) {
  61.  
  62.  do {
  63.  
  64. $tipid[$tipcount] = $myrow["tipid"];
  65. $tipcount++;
  66.  
  67.  } while ($myrow = mysql_fetch_array($result));
  68.  
  69. }
  70.  
  71. if (count($tipid) == 0) {
  72.  
  73.  printf("<tr><td colspan=3><p><center><FONT face=arial size=2><b>Niestety nic nie znaleziono</b></font></center></p></td></tr>");
  74.  
  75. } else {
  76.  
  77.  $rowcolor = 1;
  78.  
  79.  for ($d = 0; $d < count($tipid); $d++) {
  80.  
  81.  $sql = "select tipid, title, date, rating from tips where tipid = $tipid[$d]";
  82.  
  83. $result = mysql_query($sql ,$db);
  84.  
  85. if ($myrow = mysql_fetch_array($result)) {
  86.  
  87.  do {
  88.  
  89. if ($rowcolor == 1) {
  90.  $rowcolorhex = "#ffffff";
  91.  $rowcolor = 0;
  92. } else {
  93.  $rowcolorhex = "#dddddd";
  94.  $rowcolor = 1;
  95. }
  96.  
  97.  
  98. printf("<tr>");
  99. printf("<td width=300 bgcolor=%s align=center><FONT face=arial size=2><a href=tip.php?tipid=%s>%s</a></font></td>", $rowcolorhex, $myrow["tipid"], $myrow["title"]);
  100. printf("<td width=80 bgcolor=%s align=center><FONT face=arial size=2>%s</font></td>", $rowcolorhex, $myrow["date"]);
  101. printf("<td width=75 bgcolor=%s><table bgcolor=%s border=0 cellspacing=0 cellpadding=0><tr>", $rowcolorhex, $rowcolorhex);
  102.  
  103. $onstars = round($myrow["rating"]);
  104. $offstars = 5 - $onstars;
  105.  
  106. for ($i = 1; $i <= $onstars; $i++) {
  107.  printf("<td width=15 bgcolor=%s align=center valign=center><FONT face=arial size=2><img src=images/staron2.gif></font></td>", $rowcolorhex);
  108. }
  109.  
  110. for ($f = 1; $f <= $offstars; $f++) {
  111.  printf("<td width=15 bgcolor=%s align=center valign=center><FONT face=arial size=2><img src=images/staroff2.gif></font></td>", $rowcolorhex);
  112. }
  113.  
  114. printf("</tr></table></td>");
  115. printf("</tr>");
  116.  
  117.  } while ($myrow = mysql_fetch_array($result));
  118.  
  119. }
  120.  
  121.  }
  122. }
  123.  
  124.  ?>


Ten post edytował mate 14.07.2007, 11:20:50
Go to the top of the page
+Quote Post
delfinium
post 14.07.2007, 11:45:20
Post #6





Grupa: Zarejestrowani
Postów: 90
Pomógł: 6
Dołączył: 30.06.2007
Skąd: Zielona Góra

Ostrzeżenie: (0%)
-----


Coś się rozjaśniło.

W linii

  1. <?php
  2. $sql = "select tipid from tips where tip like '% $searchingred %' and status = 'L'";
  3. ?>


i zamień where tip like na where title like.
Go to the top of the page
+Quote Post
mate
post 25.07.2007, 16:42:02
Post #7





Grupa: Zarejestrowani
Postów: 50
Pomógł: 0
Dołączył: 27.06.2007

Ostrzeżenie: (0%)
-----


Zmienilem, ale tym razem nie ma zadnych wynikow w wyszukiwaniu..

jakies jeszcze poprawki wprowadzic??

i co? da sie cos z tym zrobic? snitch.gif

prosze o pomoc :]
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 13.07.2025 - 11:43