ログインしたユーザーがメモを入力して保存できる HTML のテキストエリアがあります。次のスクリプトを使用して、保存したメモをデータベースから取得します
<?php
function notes() {
$password = "fake_password";
$connect = mysql_connect("localhost", "user", $password) or die("Couldn't connect to the database!");
mysql_select_db("db_name") or die("Couldn't find the database!");
$query = mysql_query("SELECT * FROM users WHERE notes!=''");
$numrows = mysql_num_rows($query);
if ($numrows != 0) {
while ($row = mysql_fetch_assoc($query)){
$notes = $row['notes'];
}
echo $notes;
}
}
?>
それはすべてうまく機能しますが、今では、[保存] ボタンがクリックされたときにユーザーがメモ (テキストエリア) に加えた変更を保存するにはどうすればよいですか?
編集:
フォーム自体は次のとおりです。
<div class="row-fluid">
<div class="span12">
<br />
<center><textarea class="input-xxlarge" rows="15"><?php include('includes/func.php'); notes(); ?></textarea>
<br />
<button class="btn btn-primary">Save Changes</button>
</center>
</div>
</div>