Pro_Lamer4e
Registered
как може да се направи подобна търсачка
Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
<form method="post" action="search.php">
<input type="text" name="q" value="" />
<select name="type">
<option value="maps">Карти</option>
<option value="plugins">Плъгини</option>
...
</select>
<input type="submit" value="Търси" name="search" />
</form>
if($_POST['search']) {
$duma = htmlspecialchars(addslashes($_POST['q']));
$type = htmlspecialchars(addslashes($_POST['type']));
if($duma == NULL) {
echo "Въведете нещо";
}
else {
$select = mysql_query("SELECT * $type WHERE title like '$duma%' ORDER BY id") or die(mysql_error());
echo "Бяга намерени ".mysql_num_rows($select)." резултата за $duma";
while($row = mysql_fetch_assoc($select)) {
echo "$row[title] - $row[description]";
}
}
}
Styl3rbg каза:HTML:<form method="post" action="search.php"> <input type="text" name="q" value="" /> <select name="type"> <option value="maps">Карти</option> <option value="plugins">Плъгини</option> ... </select> <input type="submit" value="Търси" name="search" /> </form>
search.php
PHP:if($_POST['search']) { $duma = htmlspecialchars(addslashes($_POST['q'])); $type = htmlspecialchars(addslashes($_POST['type'])); if($duma == NULL) { echo "Въведете нещо"; } else { $select = mysql_query("SELECT * $type WHERE title like '$duma%' ORDER BY id") or die(mysql_error()); echo "Бяга намерени ".mysql_num_rows($select)." резултата за $duma"; while($row = mysql_fetch_assoc($select)) { echo "$row[title] - $row[description]"; } } }
if($_POST['search']) {
$duma = htmlspecialchars(addslashes($_POST['q']));
$type = htmlspecialchars(addslashes($_POST['type']));
if($duma == NULL) {
echo "Въведете нещо";
}
else {
$select = mysql_query("SELECT * $type WHERE title like '%$duma%' ORDER BY id") or die(mysql_error());
echo "Бяха намерени ".mysql_num_rows($select)." резултата за $duma";
while($row = mysql_fetch_assoc($select)) {
echo "$row[title] - $row[description]";
}
}
}