我正在做类似股价查找器,有数据表由股票名称,代码,价格组成。 如何将php文档合并到1个文档中?
什么我想要做的是,如果在的index.html,结果将显示在result.php用户输入股票名称,如果用户点击股票名称,描述的详细信息view.php 。无论如何,我弥补了这一点,问题是...我认为分页会与用户复杂,我想将页面合并到一个页面。不使用result.php和view.php,但只使用index.html。
就像这个...
有一些变更移动一页一页,所以我很害怕我怎么能合并该页面。用户输入文本和代码。我不知道我该如何控制它。
的index.html
<form action="./result.php" method="get">
<label>
Search
<input type="text" name="keywords">
<input type="submit" value="Search">
</label>
</form>
result.php
<?php
require_once './require/db.php';
if(isset($_GET['keywords'])){
$keywords = $db->escape_string($_GET['keywords']);
$query = $db->query("SELECT name,code FROM data2 WHERE name LIKE '%{$keywords}%' ");
?>
<div class="result-count">
Found <?php echo $query->num_rows; ?> results.
</div>
<?php
}
if($query->num_rows) {
while($r = $query->fetch_object()) {
?>
<div class="result">
<a href="./result.php?code=<?php echo $r->code;?>">
<?php echo $r->name; ?></a>
</div>
<br />
<br />
<?php
}
}
?>
view.php
<?php
require_once("./require/file_get_contents_curl.php");
$code = $_GET['code'];
$source = file_get_contents("http://www.nasdaq.com/symbol/$code");
$dom = new DOMDocument();
@$dom->loadHTML();
$stacks = $dom->getElementsByTagName('dl')->item(0)->textContent;
?>
上面的代码我狂呃。但我想合并它。我如何将3个文件合并为1个文件?因为用户输入'关键字(index.html-> result.php)'和'_GET变量(result.php-> view.php)'这对我来说非常困难。请帮帮我。
提供从文件的代码示例答案。认为它可以帮助。 –
@Gustaf非常感谢。我会马上尝试。 – Juntae
很高兴能帮到你! –