你好我想问一个问题,现在我开始使用搜索引擎,所以你能建议一些功能或方法如何开始或使用什么来通过用户名从数据库用户制作搜索引擎。它可以搜索用另一个词的一个符号我写“k”,然后它搜索所有以用户名“k”开头的用户名。示例: http: //postimg.org/image/sg84ny3w3/
试过:
private function Search()
{
global $database;
if(isset($_POST['s'])) {
if($_POST['s'] == '1' || $_POST['s'] == '2' || $_POST['s'] == '3')
$type = $_POST['s'];
$database->getSearchData($type, $_POST['xs']);
}
else if(!preg_match("/[^0-9A-Za-z]/", $_POST['xs'])){
$error = "You entered invalid data";
}
return false;
}
html:
<div id="content">
<div style="padding:20px">
<?echo $error;?>
<form action="index.php?mod=highscore&t=search" method="POST" accept-charset="utf-8">
<div class="title_box"><div class="title_inner">
What are you searching for? </div></div>
<div class="title2_box"><div class="title2_inner">
<p>
<table width="80%">
<tr>
<td><input type="radio" name="s" value="1"></td>
<td>Player</td>
</tr>
<tr>
<td><input type="radio" name="s" value="2"></td>
<td>Guild (Name)</td>
</tr>
<tr>
<td><input type="radio" name="s" value="3"></td>
<td>Guild (Guild Tag)</td>
</tr>
<tr>
<td>Text:</td>
<td colspan="2"><input type="text" name="xs" size="30" maxlength="30" value=""></td>
</tr>
<tr>
<td colspan="3"><input type="submit" value="Search" class="button3" name="search"></td>
</tr>
</table>
</p>
</form>
</div></div>
<br />
<?if($functions->Search() == false) {?>
<div class="title_box"><div class="title_inner">
Results </div></div>
<div class="title2_box"><div class="title2_inner">
<p>
<table width="50%">
<tr>
<td>Player</td>
<td>Level</td>
<td>Total honour</td>
</tr>
<tr><td class="f" colspan="2">No results</td></tr></table> </p>
</div></div>
<?} else {?>
<div class="title_box"><div class="title_inner">
Results </div></div>
<div class="title2_box"><div class="title2_inner">
<p>
<table width="50%">
<tr>
<td>Player</td>
<td>Level</td>
<td>Total honour</td>
</tr>
<tr><td class="f" colspan="2"><?$functions->Search();?></td></tr></table> </p>
</div></div>
<?}?>
</div>
<script type='text/javascript'>var tickerArray = new Array();function doTicker(){
n=new Date();
if (tickerArray.length > 0)
{
for (i = 0; i < tickerArray.length; i++)
{
if (isNaN(document.getElementById(tickerArray[i]["id"])))
{
var e = document.getElementById(tickerArray[i]["id"]);
s = tickerArray[i]["sek"];
m = 0;
h = 0;
d = 0;
if (s < 0)
e.innerHTML = "---";
else
{
var timeTXT = s + " s";
if (s > 59)
{
m = Math.ceil(s / 60);
s = s-m * 60;
timeTXT = m + " m";
}
if (m > 59)
{
h = Math.ceil(m / 60);
m = m - h * 60;
timeTXT = h + " h";
}
if (h > 24)
{
d = Math.ceil(h / 24);
h = h-d * 24;
timeTXT = d + " d";
}
e.innerHTML = timeTXT;
tickerArray[i]["sek"]--;
}
}
}
window.setTimeout("doTicker();",999);
}
}doTicker();</script>
</div>