Jump to content
php.lv forumi

Search


ziedinjsh

Recommended Posts

Pilnīgi nav ne jausmas, bet nu kā izveidot meklēšanas sistēmu, piem. man vajadzētu meklēt lietotājus..

vienīgais ko es zinu ar ko sākt ir šis :D

<form method='post' action='search.php'>
<input type='text' name='user'><input type='submit' name='user' value='Search'>
</form>

 

kādam būtu jāizskatās search.php nav ne jausmas.

 

Ceru uz palīdzību, paldies jau iepriekš :)

Link to comment
Share on other sites

ja sapratu pareizi tad nu man ir tā: Tabula users, zem kuras ir - user_id, username, password, email, location, genre, avatar un date.

 

un gribu lai search formā ierakstot vismaz 3 simbolus vai vairāk viņš atrod username kurā ir šie simboli.

 

Piemēram, es ierakstu: edin un viņš man atrod ziedinjsh un tml. :)

Edited by ziedinjsh
Link to comment
Share on other sites

$sql = mysql_query("SELECT * FROM users WHERE username LIKE '%".mysql_real_escape_string($_POST['user'])."%'");
while($data = mysql_fetch_array($sql)) {
echo $data['username'].' ';
}

Link to comment
Share on other sites

Tātad, tagad man ir šādi:

 

form:

echo "<form method='post' action='search.php'>";
echo "<input type='text' name='username'><input type='submit' name='username' value='Search'>";
echo "</form>";

 

search.php

if(isset($_POST['username'])){

$sql = mysql_query("SELECT * FROM users WHERE username LIKE '%".mysql_real_escape_string($_POST['username'])."%'");
while($row = mysql_fetch_array($sql)) {

echo $row['username'].' ';

}

Ko es esmu palaidis garām, vai netā izdarījis, jo uzspiežot search atveras search.php tukš?

Edited by ziedinjsh
Link to comment
Share on other sites

input pogai name atribūta vērtību nomaini uz ko citu lai nav vienāda ar input text name vērtību

Edited by Pentiums
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...