Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Dobra wyszukiwarka ?
ewelinac18
post 16.09.2007, 08:40:27
Post #1





Grupa: Zarejestrowani
Postów: 99
Pomógł: 0
Dołączył: 11.07.2007

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


Poszukuje dobrej wyszukiwarki sama bym coś napisała ale wole coś optymalnego
aby nie obciążyć bazy danych

słyszałam ze LIKE nie jest zbyt optymalnym rozwiązaniem

Może macie jakieś namiary na fajne skrypty wyszukiwarek

co sądzicie o tym:


  1. <head>
  2. <link rel="stylesheet" type="text/css" href="includescss.css">
  3. </head>
  4. <html> 
  5.  <body>
  6. <font face="tahoma" size="4"> <font face="Verdana, Arial, Helvetica, sans-serif">Mysql 
  7. Search</font></font> 
  8. <form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post">
  9. <font face="Verdana, Arial, Helvetica, sans-serif"> Specific Word or Phrase 
  10. <input type="text" name="words" value="<?php echo($words); ?>">
  11. <br>
  12. <br>
  13. <input type="hidden" name="good" value="yes">
  14. <input type="submit" value="Search">
  15. </font>
  16. </form>
  17. <p><font face="Verdana, Arial, Helvetica, sans-serif"><br>
  18. <br>
  19. <? 
  20. /*
  21. This script is set up specifically for me so some things will need changing.
  22. I made this script because there is a lack of good mysql serching scripts out th
    ere.
  23. */
  24. if($_POST['good']=='yes') 
  25. { 
  26.  echo("<font face=\"tahoma\" size=\"3\" color=\"green\"><b>Results for $words</b></font><br><br>"); 
  27.  $location = "xxx"; // database host (localhost)
  28.  $username = "xxx"; // mysql username
  29.  $password = "xxx"; //mysql password
  30.  $database = "xxx"; //mysql database name
  31.  $db_table = "xxx"; // mysql table name to search
  32.  $mysql_row = "xxx"; // This is the row in your mysql database that you want to search for text in.
  33.  
  34.  $conn = mysql_connect("$location","$username","$password"); 
  35.  if (!$conn) die ("Could not connect MySQL"); 
  36.  mysql_select_db($database,$conn) or die ("Could not open database"); 
  37.  
  38.  $query = "ALTER TABLE $db_table ORDER BY id DESC"; 
  39.  $result = mysql_query($query); // bad coding yes ;)
  40.  
  41.  $query = "SELECT * FROM $db_table"; 
  42.  $result = mysql_query($query); 
  43.  $numrows = mysql_num_rows($result); 
  44.  while($row = mysql_fetch_array($result)){ 
  45.  
  46.  if(preg_match("/$words/i", $row[$mysql_row]))
  47.  { 
  48.  
  49. /*
  50. event_id
  51. event_date
  52. event_venue
  53. event_headline
  54. event_town
  55. are all rows in my mysql table. You must replace them with your own rows / rows
  56. */
  57.  
  58. $rawid = ($row[event_id]); 
  59. $rawmonth = ($row[event_date]); //yes strange variable names. It works so it doesnt matter.
  60. $rawdate = ($row[event_venue]); //T just grab extra data to be added with the search tool
  61. $rawyear = ($row[event_headline]); 
  62. $newnews = preg_replace("/$words/i", "<b><font color=\"red\">$words</font></b>", $row[$mysql_row]); 
  63. $display = '<font face="tahoma" size="2"><b>' .$rawmonth . ' ' . $rawdate . ', ' . $rawyear . '</b><br>' . $newnews . '</font><br><br>'; 
  64. echo($display); 
  65. $foundcount++; 
  66.  } 
  67.  $totalcount++; 
  68.  } 
  69. if(is_null($foundcount)){$foundcount=0;} 
  70. echo("<font face=\"tahoma\" size=\"3\" color=\"green\"><b>Found $foundcount entries out of $totalcount</b></font>"); 
  71. } 
  72. ?>
  73. <br>
  74. A mysql searching tool made by <a href="http://www.gmtt.co.uk">gmtt.co.uk</a></font></p>
  75. <p>&nbsp;</p>
  76. <p><font face="Verdana, Arial, Helvetica, sans-serif"> the rows (event_date, event_venue 
  77. etc etc) are used for<br>
  78. displaying extra information about the search result.</font></p>


Ten post edytował ewelinac18 16.09.2007, 08:58:40
Go to the top of the page
+Quote Post
skowron-line
post 16.09.2007, 08:44:57
Post #2





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

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


sory za OT
  1. <?php
  2.  $location = "xxx"; // database host (localhost)
  3.  $username = "xxx"; // mysql username
  4.  $password = "xxx"; //mysql password
  5.  $database = "xxx"; //mysql database name
  6.  $db_table = "xxx"; // mysql table name to search
  7. ?>

jezeli to sa prawdziwe dane to gratuluje

*edit dane ukryte na przyszlosc pamietaj o takich rzeczach bo mozesz miec nieprzyjemnosci

Ten post edytował skowron-line 16.09.2007, 11:40:28


--------------------
I'm so fast that last night I turned off the light switch in my hotel room and was in bed before the room was dark - Muhammad Ali.
Peg jeżeli chcesz uprawiać sex to dzieci muszą wyjść, a jeżeli chcesz żeby był dobry ty też musisz wyjść - Al Bundy.

QueryBuilder, Mootools.net, bbcradio1::MistaJam
http://www.phpbench.com/
Go to the top of the page
+Quote Post
ewelinac18
post 16.09.2007, 08:59:54
Post #3





Grupa: Zarejestrowani
Postów: 99
Pomógł: 0
Dołączył: 11.07.2007

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


niestety wpadka :/ zdążyłam zmienic
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: 19.07.2025 - 11:42