我想从mysql数据库打印一个列表,但第一个列表项不打印,因为mysql_fetch_array被调用两次.我尝试重置但它没有用.我该怎么办?
$current_goam = mysql_real_escape_string($current_goam);
$current_content = mysql_real_escape_string($current_content);
$note_content = mysql_query("select * from notes where title='$current_content' and goam='$current_goam' and user_id='$user_id'");
$note = mysql_fetch_array( $note_content );
if($note['type'] == 'list')
{
$note_type='list';
reset($note);
print "<table>";
while($note_info = mysql_fetch_array( $note_content ))
{
print "<tr><td>";
echo $note_info['body'];
print "</td>";
echo "<td><input type='checkbox' name='complete_goal' value='".$note_info['note_id']."'></input></td>";
print "</tr>";
}
print "</table>";
}
else{
echo $note['body'];
}
Run Code Online (Sandbox Code Playgroud) 我无法弄清楚为什么这不起作用.它说"注释已添加"但它实际上并没有将它添加到数据库中.
<?php
$notetitle = $_POST['title'];
$notebody = $_POST['body'];
if ($notetitle && $notebody){
mysql_query("insert into notes values
('$user_id', '', '$subject', '$notetitle', '$note_type' '$notebody')");
echo "Note \"" . $notetitle . "\" added.";
}
Run Code Online (Sandbox Code Playgroud)
?>
<?php
$current_subject = $_GET['subject_id'];
$current_content = $_GET['note_id'];
echo "<form method=\"post\" action=mainpage.php?subject_id=".$current_subject."¬e_id=".$current_content.">";
?>
<input type='text' name='list_item' value=''>
<input type='submit' name="new_item" value="New Item">
</form>
Run Code Online (Sandbox Code Playgroud)
问题是,当其中一个GET变量是两个单词时,链接就不会这样写.例如,如果$current_subject="Advanced Chemistry"和$current_content="Valence Electrons"链接将出现如下:
<form method=?"post" action=?"mainpage.php?subject_id=Advanced" chemistry¬e_id=?"Valence" electrons>?
Run Code Online (Sandbox Code Playgroud) 当我刷新php页面时,有没有办法避免重新处理表单?我想在刷新带有插入功能的php文件的链接时阻止重新发送表单.例如,我正在处理用户在每页顶部写的一系列笔记,以获得新笔记.除了明显创建一个带有头功能的单独的php文件之外还有另外一种方法吗?