我正在尝试让我的编辑页面适用于我的简单新闻系统。我想要它做的是在点击时显示所有新闻项目,它确实如此,但是我希望能够点击标题并被重定向到开关并显示一个包含该特定标题的所有信息的表单,然后可以对其进行编辑。不幸的是,每当我点击标题时,什么都没有发生。
<html>
<head>
<link rel="stylesheet" type="text/css" href="includes/style.css" />
</head>
<body>
<div align="center" /><font size="20px;" />#test</font></div>
<?php include("includes/navigation.php"); ?>
<fieldset><legend>Article editting</legend>
<?php
$idGlobal;
include("includes/config.php");
global $idGlobal;
if(isset($_GET['x'])) {
$x = $_GET['x'];
switch($x) {
case "$idGlobal":
if(is_null($idGlobal)) {
// if $the_id variable is null (empty) it will display the message below.
echo("Error. No id pushed.");
} elseif(isset($idGlobal)) {
// if $the_id variable is set (is storing a variable) it will display the form below.
$result = mysql_query("SELECT * FROM posts WHERE id=$idGlobal") or die(mysql_error());
while($row = mysql_fetch_array($result)) {
echo('<form action="includes/process.php?x=edit" method="post" />');
echo('<input name="title" type="text" value="$row[\'title\']"/><br />');
echo('<input name="date" type="text" value="$row[\'date\']"/><br />');
echo('<textarea rows="4" cols="50" name="text" />$row[\'text\'];</textarea><br />');
echo('<input name="author" type="text" value="$row[\'Author\']"/><br />');
echo('<input type="submit" />');
echo('</form>');
}
}
break;
default:
echo("<table>");
echo("<tr><th>ID</th><th>Title</th><th>Date</th><th>Author</th></tr>");
while($row = mysql_fetch_array($result)) {
$id = $row['id'];
echo "<tr><td>";
echo $row['id'];
echo "</td><td>";
echo("<a href=\"edit.php?x=$id\" />" .$row['title'] . "</a>");
echo("</td><td>");
echo $row['date'];
echo("</td><td>");
echo $row['author'];
echo("</td></tr>");
$idGlobal = $id;
}
break;
}
} else {
echo("<table>");
echo("<tr><th>ID</th><th>Title</th><th>Date</th><th>Author</th></tr>");
while($row = mysql_fetch_array($result)) {
$id = $row['id'];
echo "<tr><td>";
echo $row['id'];
echo "</td><td>";
echo("<a href=\"edit.php?x=$id\" />" .$row['title'] . "</a>");
echo("</td><td>");
echo $row['date'];
echo("</td><td>");
echo $row['author'];
echo("</td></tr>");
$idGlobal = $id;
}
}
?>
</fieldset>
</body>
</html>