Zoek Script

Gestart doorWouterr4 reacties61 weergaven

5 berichten · pagina 1 van 1

Wouterr

Lid · Topicstarter

Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

Hey,

Ik ben bezig met een ledensysteem voor nlminecraft cooolalleen ik wil dus dat mensen spelers kunnen zoeken.
Ik heb nu dit:

[COLOR= #0000BB]<?php[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]))
        {[/COLOR]
            [COLOR= #0000BB]$zoek_query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM leden WHERE (naam LIKE "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]"% OR  naam LIKE %"[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]") LIMIT 1"[/COLOR][COLOR= #007700]);[/COLOR]
            
            [COLOR= #0000BB]$zoek[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$zoek_query[/COLOR][COLOR= #007700]);[/COLOR]
            
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$zoek_query[/COLOR][COLOR= #007700]) !=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
            {[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Gevonden! We versturen je door.[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<meta http-equiv="refresh" content="3; url=http://www.nlminecraft.nl/?leden=home&mcnaam=[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$zoek[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]">[/COLOR][COLOR= #007700];    
            }[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<form action="" method="POST"><label for="naam"><b>Naam:</b></label><br/><input type="text" name="naam" id="naam"/><input type="hidden" name="leden" id="leden" value="zoek"><br/><input type="submit" name="submit" id="submit" value="Zoek!"></form>[/COLOR][COLOR= #007700];
            }
        }[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<form action="" method="POST"><label for="naam"><b>Naam:</b></label><br/><input type="text" name="naam" id="naam"/><input type="hidden" name="leden" id="leden" value="zoek"><br/><input type="submit" name="submit" id="submit" value="Zoek!"></form>[/COLOR][COLOR= #007700];
        }[/COLOR]
        ?>


Nu kunnnen ze als ze wouter0100 zoeken dit intypen:
0100
wouter
Enzovoort, Alleen bijvoorbeeld niet:
r010
out
enzovoort.
Hoe zorg ik dat dit wel kan?
Ik dacht val van elke letter splitsen enz..
maar dat is dan ook weer zo veel werk.

Iemand die hier een simpele oplossing voor weet?

Alvast bedankt!
WOuter
0
Berichten
2.609
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik gebruik

[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]zoeken[/COLOR][COLOR= #007700]]) && ![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]string[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]string[/COLOR][COLOR= #007700]]) >[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700]) {[/COLOR]
    [COLOR= #0000BB]$string[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]string[/COLOR][COLOR= #007700]]);[/COLOR]
    
    
    
    
    [COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT profiel.*,leden.gebruikersnaam FROM profiel LEFT JOIN leden ON (profiel.member_id = leden.member_id) WHERE profiel.naam LIKE %$string% OR profiel.achternaam LIKE %$string% OR profiel.woonplaats LIKE %$string% OR profiel.website LIKE %$string% OR profiel.grootprofiel LIKE %$string% OR profiel.favo_fansite LIKE %$string% OR profiel.favo_kamer LIKE %$string% OR leden.gebruikersnaam LIKE %$string%"[/COLOR][COLOR= #007700];[/COLOR]        
    
    [COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Er zijn geen profielen gevonden met deze zoekwoorden.<br />"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<br /><br />Zoek nog een keer:<br>"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/include_once"]include_once[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]pagina/zoekformulier.php[/COLOR][COLOR= #007700]);
    }[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"
        <table>
            <tr>
                <td><strong>Gebruikersnaam</strong></td>
            </tr>"[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]
    
        [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700])) {[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"
                <tr>
                    <td><a href=?p=profiel&mid="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]member_id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]">"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"</a></td>
                </tr>"[/COLOR][COLOR= #007700];
        }[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</table>"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<br />Zoek nog een keer :"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]pagina/zoekformulier.php[/COLOR][COLOR= #007700]);    
    }
    

}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
?><center>
<form action="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]PHP_SELF[/COLOR][COLOR= #007700]];[/COLOR] ?>?p=profiel&a=zoeken" method="post">
    <table class="body" width="300">
        <tr>
            <td>Zoeken</td>
            <td><input type="text" name="string" /></td>
        </tr>
    [COLOR= #0000BB]<?php[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]zoeken[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]string[/COLOR][COLOR= #007700]])) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"
        <tr>
            <th colspan="2">De string is leeg, Hier kan ik toch niet mee werken!</th>
        </tr>"[/COLOR][COLOR= #007700];
    }[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]zoeken[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]string[/COLOR][COLOR= #007700]]) <=[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700]) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"
        <tr>
            <th colspan="2">Je woord moet meer dan 3 tekens bevatten.</th>
        </tr>"[/COLOR][COLOR= #007700];
    }[/COLOR]
    ?>
        <tr>
            <th colspan="2"><input type="submit" name="zoeken" value="Zoeken" /></th>
        </tr>
    </table>
</form></center>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}[/COLOR]

?>


Als ik "Nick" invul krijg ik een lijstje waar Nickjexx tussen staat, zo als bijvoorbeeld een ander lid "DJ-NickThunder" die staan er ook tussen, want er zit "Nick" in de naam.

Dus misschien heb je wat aan die codeemo
0
Wouterr

Lid · Topicstarter

Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

Hmm, ja oké yummie
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
LIKE %".mysql_real_escape_string($_POST[naam])."%
En dan die andere OR weghalen?
Want nu zoekt hij OF er voor iets, OF erachter en als je aan alle 2 de kanten een %-teken zet en die OR erachter weghaalt (En wat erbij de OR hoort) dan zoekt hij ervoor en erachter tegelijk..?
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Xjessex schreef:
LIKE %".mysql_real_escape_string($_POST[naam])."%
En dan die andere OR weghalen?
Want nu zoekt hij OF er voor iets, OF erachter en als je aan alle 2 de kanten een %-teken zet en die OR erachter weghaalt (En wat erbij de OR hoort) dan zoekt hij ervoor en erachter tegelijk..?
Inderdaad, vervang

$zoek_query = mysql_query("SELECT * FROM leden WHERE (naam LIKE ".mysql_real_escape_string($_POST[naam])."% OR  naam LIKE %".mysql_real_escape_string($_POST[naam]).") LIMIT 1");


door

$zoek_query = mysql_query("SELECT * FROM leden WHERE (naam LIKE %".mysql_real_escape_string($_POST[naam])."%) LIMIT 1");


En hoezo LIMIT 1? Als iemand door je leden wilt zoeken heeft die vast graag meer resultaten smile
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren