jqueryでCRUDアプリケーションを作成していますが、アプリケーションでこの問題が発生しています。レコードを編集するには、レコードのIDを正常に取得しています。
<a href="#" id="<?php echo $msg_id; ?>" class="update_btn">Edit</a>
IDを取得したいのですが、うまくいきます。
$('.update_btn').live("click",function()
{
var ID = $(this).attr("id");
var dataString = 'msg_id='+ ID;
//alert(dataString);
$.ajax({
type: "POST",
url: "get-data.php",
dataType: 'json',
cache: false,
success: function(data){
//getData()
}
});
return false;
});
ただし、取得したIDを使用するにはどうすればよいですか
//get-data.php
include('db.php');
if($_POST['msg_id'])
{
$id=$_POST['msg_id'];
$id = mysql_escape_String($id);
$sql_in= mysql_query("SELECT msg FROM messages where msg_id='$id'");
$r=mysql_fetch_array($sql_in);
$msg=$r['msg'];
echo json_encode($msg);
}
選択クエリからデータを返します。これは可能ですか?