Pomoc - Szukaj - U¿ytkownicy - Kalendarz
Pe³na wersja: Dobra wyszukiwarka ?
Forum PHP.pl > Forum > Gotowe rozwi±zania > Szukam
ewelinac18
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>
skowron-line
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
ewelinac18
niestety wpadka :/ zd±¿y³am zmienic
To jest wersja lo-fi g³ównej zawarto¶ci. Aby zobaczyæ pe³n± wersjê z wiêksz± zawarto¶ci±, obrazkami i formatowaniem proszê kliknij tutaj.
Invision Power Board © 2001-2024 Invision Power Services, Inc.