2 つのファイルを使用して検索します。 index.html
PHP 検索関数を呼び出すフォームを作成します ( ss.php
)
index.html コード:
<form action="ss.php" method="get">
<input name="q" type="text">
<input type="submit">
</form>
および ss.php コード (php 検索機能):
<?php
$dir = 'ups';
$exclude = array('.','..','.htaccess');
$q = (isset($_GET['q']))? strtolower($_GET['q']) : '';
$res = opendir($dir);
while(false!== ($file = readdir($res))) {
if(strpos(strtolower($file),$q)!== false &&!in_array($file,$exclude)) {
echo "<a href='$dir/$file' target = '_blank'>$file</a>";
echo "<br>";
}
}
closedir($res);
?>
入力パラメータの長さが 8 桁のときに検索を開始したい。
編集:
解決されたすべてのボディのおかげで、私はこのコードを使用しました:
<form action="ss.php" method="get"><input name="q"
type="text" pattern=".{8,10}" title="8 to 10 characters" maxlength="10">
<input type="submit"></form>