【发布时间】:2013-02-27 19:31:21
【问题描述】:
我制作了一个在类别中搜索文件的脚本。我的问题是:搜索脚本后不显示搜索结果。示例:我正在搜索类似 :-? 的游戏交流3。搜索后脚本不显示任何结果。一些帮助?
<html>
<body>
<center>
<font color="black" size="4">
<?php
//define each directory here, the index starts with 0 == all and so on.
$categorydir = array('/Category/All/', '/Category/PCGames/', '/Category/Console/', '/Category/Movies/', '/Category/Music/', '/Category/XXX/', '/Category/Windows/', '/Category/Linux/', '/Category/Software/', '/Category/Documents/');
//if option selected and its valid number
if (isset($_POST['category']))
if(ctype_digit($_POST['category']) && isset($categorydir[$_POST['category']]))
if(array_key_exists($_POST['category'], $categorydir) && is_dir($categorydir[$_POST['category']])){
is_dir($categorydir[$_POST['category']]);
$files = scandir($categorydir[$_POST['category']]);
echo 'target directory not found';
echo 'Results of search:<br></br>';
foreach($files as $file){
echo($file);
}
?>
</font>
</center>
</body>
</html>
<html>
<head>
<title>DataHunters</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="header">
<h1 id="logo"><a href="index.html">DataHunters</a>
</h1>
</div>
<div id="navigation">
<ul>
<li><a class="active" href="index.html">Home</li></a>
<li><a href="chat.html">Chat</li></a>
<li><a href="contact.html">Contact</li></a>
<li><a href="http://www.forum.datahunters.ro">Forum</li></a>
</ul>
</li>
</div>
</body>
</html>
【问题讨论】:
-
你期待什么输出?
-
我期待在搜索后发布结果的脚本。
-
您对结果有何期待?除了“找不到目标目录”和“搜索结果:”之外,您没有在上面的代码中输出任何内容:
-
很难阅读你的代码。使用更多的大括号。
-
所以,看这里。我想要的只是一个在类别中浏览文件然后显示该文件的脚本。我制作的脚本有一些错误,我期待你或其他任何人删除这些错误。(抱歉英语不好)
标签: php file search-engine displayobject