php表单回显不工作
我正在运行select语句来检索db值。然后,将检索到的数据显示/回显到表单字段中 “作者”数据在“作者”字段中正确显示 “关键字”数据显示正确 但是,来自“content”变量的数据没有显示在表单文本区域中。 我知道语句中缺少值=,但这没有什么区别 我已经使用echo确认$content变量包含所需的数据 我错过了什么明显的东西吗?非常感谢您的帮助:php表单回显不工作,php,forms,Php,Forms,我正在运行select语句来检索db值。然后,将检索到的数据显示/回显到表单字段中 “作者”数据在“作者”字段中正确显示 “关键字”数据显示正确 但是,来自“content”变量的数据没有显示在表单文本区域中。 我知道语句中缺少值=,但这没有什么区别 我已经使用echo确认$content变量包含所需的数据 我错过了什么明显的东西吗?非常感谢您的帮助: <?php if(isset($_GET['edit_post'])) { $edit_id = $_GET['edit_po
<?php
if(isset($_GET['edit_post'])) {
$edit_id = $_GET['edit_post'];
$select_post = "select * FROM posts WHERE post_id = '$edit_id'";
run_query = mysql_query($select_post);
while($row_posts = mysql_fetch_array($run_query)) {
$author = $row_posts['post_author'];
$keywords = $row_posts['post_keywords'];
$content = $row_content['post_content'];
}
}
?>
<tr>
<td align="right" bgcolor="#ccc"> Author:</td>
<td><input type="text" name="post_author" value ="<?php echo $author;?>"/></td>
</tr>
<tr>
<td align="right" bgcolor="#ccc"> Keywords:</td>
<td><input type="text" name="post_keywords" size="100" value ="<?php echo $keywords;?>"/></td>
</tr>
<tr>
<td align="right" bgcolor="#ccc"> Content:</td>
<td><textarea name="post_content" rows="10" cols="60"><?php echo $content;?> </textarea></td>
</tr>
非常感谢,,
P您错误地访问了$content
当您将查询结果存储在$row_posts中时,它应该是$content = $row_posts['post_content'];
您错误地访问了$content
当您将查询结果存储在$row_posts中时,它应该是
$content = $row_posts['post_content'];
试试这个
<?php
if(isset($_GET['edit_post'])) {
$edit_id = $_GET['edit_post'];
$select_post = "select * FROM posts WHERE post_id = '$edit_id'";
$run_query = mysql_query($select_post);
$author = "";
$keywords = "";
$content = "";
if(mysql_num_rows($run_query)>0) {
$row_posts = mysql_fetch_array($run_query);
$author = $row_posts['post_author'];
$keywords = $row_posts['post_keywords'];
$content = $row_posts['post_content'];
}
}
?>
试试这个
<?php
if(isset($_GET['edit_post'])) {
$edit_id = $_GET['edit_post'];
$select_post = "select * FROM posts WHERE post_id = '$edit_id'";
$run_query = mysql_query($select_post);
$author = "";
$keywords = "";
$content = "";
if(mysql_num_rows($run_query)>0) {
$row_posts = mysql_fetch_array($run_query);
$author = $row_posts['post_author'];
$keywords = $row_posts['post_keywords'];
$content = $row_posts['post_content'];
}
}
?>
使用这个$content=$row_posts['post_content']
而不是$content=$row_content['post_content'] 使用这个$content=$row_posts['post_content']
而不是$content=$row_content['post_content']