我正在尝试在file_lock
内传递文本并在我的sql数据库中更新它但我确实想要在<textbox>
中已经存在一些文本,如图所示,所以我无法要点击按钮或链接时将<textbox>
内的文字传递给textbox
,我也必须传递变量edit_note.php
。
的index.php
$note_id
edit_note.php
$note_query = mysql_query("SELECT * FROM `notes` WHERE `id` = $note_id AND `user_id`='$my_id'");
while ($run_note = mysql_fetch_assoc($note_query)) {
$note_text = $run_note['text'];
$note_date = $run_note['Note_added_dat'];
}
echo $edit_text = "<textarea id='note'>$note_text</textarea><br><br>";
echo <a href='edit_note.php?note=$note_id&edit=$edit_text>EDIT</a>/*click this to update note*/
输出
答案 0 :(得分:1)
尝试这样的事情:
<?php
$note_query = mysql_query("SELECT * FROM `notes` WHERE `id` = $note_id AND `user_id`='$my_id'");
while ($run_note = mysql_fetch_assoc($note_query)) {
$note_text = $run_note['text'];
$note_date = $run_note['Note_added_dat'];
}
?>
<form method="GET" action="edit_note.php">
<input type="hidden" name="note" value="<?php echo $note_id;?>">
<textarea name="edit"><?php echo $note_text;?></textarea>
<input type="submit" value="Edit">
</form>
答案 1 :(得分:1)
<?php
$default_text = "Something";
$note_query = mysql_query("SELECT * FROM `notes` WHERE `id` = $note_id AND `user_id`='$my_id'");
while ($run_note = mysql_fetch_assoc($note_query)) {
$note_id = $run_note['id'];
$note_text = $run_note['text'];
$note_date = $run_note['Note_added_dat'];
}
if( isset($note_text) )
echo $edit_text = "<textarea id='note'>$note_text</textarea><br><br>";
else
echo $edit_text = "<textarea id='note'>$default_text</textarea><br><br>";
echo "<a href='edit_note.php?note=$note_id&edit=$edit_text>EDIT</a>"; /*click this to update note*/
?>
edit_note.php
<?php
if(isset($_GET['note']) && !empty($_GET['note'])) {
$my_id = $_SESSION['user_id'];
echo $note_id=$_GET['note'];
echo $edit_note = str_replace("\r\n", "<br>", $_GET['edit']);
}
if (mysql_query("UPDATE `notes` SET `text`='$edit_note',`Note_added_dat`= now() WHERE `note_id` ='$note_id' AND `user_id` = '$my_id'")) {
{
echo 'Note has been Edited';
}
}
?>