我正在尝试在我的网站上创建动态页面,但它失败了。当我尝试它的代码时,Xampp
它工作得很好。还有一点我不明白。它将捕获 id,但不会捕获标题或数据库中包含字符的任何内容。当我尝试$title = $_GET['title'];
它不会工作。它仅适用于$_GET['id'];
任何帮助?
这是代码:
索引.php
<?php
include('inc/code.inc.php');
$fetch = mysql_query("SELECT * FROM `star` ORDER BY `title`");
while ($output = mysql_fetch_assoc($fetch))
{
echo '<a href = "run.inc.php?id='. $output['id'] .'">'. $output['title'] .'</a><br />';
}
?>
运行.inc.php
<?php
include_once('inc/code.inc.php');
$newID = $_GET['id'];
$fetch = mysql_query("SELECT * FROM `star` WHERE `id` = $newID");
while ($output = mysql_fetch_assoc($fetch))
{
echo $output['title'] . '<br />' . $output['explain'];
}
?>
这是不起作用的代码:
索引.php
<?php
include('inc/code.inc.php');
$fetch = mysql_query("SELECT * FROM `star` ORDER BY `title`");
while ($output = mysql_fetch_assoc($fetch))
{
echo '<a href = "run.inc.php?title='. $output['title'] .'">'. $output['title'] .'</a><br />';
}
?>
运行.inc.php
<?php
include_once('inc/code.inc.php');
$newID = $_GET['title'];
$fetch = mysql_query("SELECT * FROM `star` WHERE `title` = $newID");
while ($output = mysql_fetch_assoc($fetch))
{
echo $output['title'] . '<br />' . $output['explain'];
}
?>