FT3 Posted November 4, 2010 Report Share Posted November 4, 2010 Mekleju google neko atrast nevareju ka lai ustaisit search scriptu ? :) Quote Link to comment Share on other sites More sharing options...
Rincewind Posted November 4, 2010 Report Share Posted November 4, 2010 Meklē "mysql LIKE" un "mysql MATCH AGAINST" Quote Link to comment Share on other sites More sharing options...
Rincewind Posted November 4, 2010 Report Share Posted November 4, 2010 Īsumā (meklēt visus vārdus, ja laukam ir izveidots full-text indekss) $searcharray=explode(" ",substr($_GET['search'],0,50)); foreach($searcharray as $word){ $searchstring.="+".$word."* "; } $searchstring=check_input($searchstring); //mysql_real_escape_string utt $q=sprintf("SELECT * FROM tabula WHERE MATCH (lauks) AGAINST (%s IN BOOLEAN MODE)", $searchstring); $result=mysql_query($q); Tūlīt mefisto ieteiks atteikties no mysql_* :) Quote Link to comment Share on other sites More sharing options...
FT3 Posted November 4, 2010 Author Report Share Posted November 4, 2010 (edited) un ka lai ar input ? :D jo es nesaprotu neko no funkcijam :D un uz 7linijas erros Fatal error: Call to undefined function check_input() in C:\AppServ\www\modules\search.php on line 7 Edited November 4, 2010 by FT3 Quote Link to comment Share on other sites More sharing options...
Rincewind Posted November 4, 2010 Report Share Posted November 4, 2010 un ka lai ar input ? :D jo es nesaprotu neko no funkcijam :D $_GET['search'] ir lietotāja inputs. Viņu vispirms sadala atsevišķos vārdos, pieliek tiem priekšā "+" un beigās "*", lai meklētu visus vārdus un varētu meklēt arī nepilnus vārdus. Tālāk parasts SELECT, tikai ar MATCH AGAINST nosacījumu. Quote Link to comment Share on other sites More sharing options...
Rincewind Posted November 4, 2010 Report Share Posted November 4, 2010 un ka lai ar input ? :D jo es nesaprotu neko no funkcijam :D un uz 7linijas erros Fatal error: Call to undefined function check_input() in C:\AppServ\www\modules\search.php on line 7 Tā nav PHP funkcija, es vienkārši caur tādu visus SQLam domātos datus izdzenu cauri. function check_input($value){ if (!is_numeric($value)){ $value = "'" . mysql_real_escape_string($value) . "'"; } return $value; } Quote Link to comment Share on other sites More sharing options...
FT3 Posted November 4, 2010 Author Report Share Posted November 4, 2010 itka ta ? <form method="post" action="?go=search"> <input type="text" name="search" /> <input type="submit" name="search" value="OK" /> </form> tavs kods ! <?php $searcharray=explode(" ",substr($_GET['search'],0,50)); foreach($searcharray as $word){ $searchstring.="+".$word."* "; } $searchstring=check_input($searchstring); $q=sprintf("SELECT * FROM movie WHERE MATCH (title) AGAINST (%s IN BOOLEAN MODE)", $searchstring); $result=mysql_query($q); ?> met erroru Fatal error: Call to undefined function check_input() in C:\AppServ\www\modules\search.php on line 7 Quote Link to comment Share on other sites More sharing options...
FT3 Posted November 4, 2010 Author Report Share Posted November 4, 2010 es neko nerubos :D:D šajos kodos :D Quote Link to comment Share on other sites More sharing options...
localhero Posted November 4, 2010 Report Share Posted November 4, 2010 Uztaisi funkciju check_input() kura parbauda ievades datus, vai arii iznjem ārā to rindinju. Protams ja skriptu taisi reālai lietošanai internetā tad es ieteiktu tomēr pārbaudīt ievades datus pret injekcijām, garumu u.c. Quote Link to comment Share on other sites More sharing options...
localhero Posted November 4, 2010 Report Share Posted November 4, 2010 es neko nerubos :D:D šajos kodos :D Es protams ar to nelielītos. Iespējams ka vieglāk būs samaksāt kādam kurš rubās, lai uztaisa. Quote Link to comment Share on other sites More sharing options...
daGrevis Posted November 4, 2010 Report Share Posted November 4, 2010 Uztaisi funkciju check_input() kura parbauda ievades datus, vai arii iznjem ārā to rindinju. Protams ja skriptu taisi reālai lietošanai internetā tad es ieteiktu tomēr pārbaudīt ievades datus pret injekcijām, garumu u.c. Nu tad ko Tu te, pie velna, dari??! Idiots. Quote Link to comment Share on other sites More sharing options...
localhero Posted November 4, 2010 Report Share Posted November 4, 2010 Mēģinu palīdzēt cilvēkam atrisināt problēmas. Ja tev ir problēmas varu arī tavējās atrisināt. Quote Link to comment Share on other sites More sharing options...
daGrevis Posted November 4, 2010 Report Share Posted November 4, 2010 Localhero, vari nemaz nemēģināt. He, he. xD Sajaucu Tevi ar FT3. Tu patiešām centies. =) 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.