我是PHP新手。我有一个代码,我使用多个内联文本编辑器。为了参考,我有一个链接JQuery Widgets Inline Text Editor 对于每个文本编辑器,我使用多个div。现在我想将我的div数据存储在Mysql db中。但我现在不知道如何在变量中获取div数据?我只需要帮助语法如何在mysql db中存储div数据
这是我的代码
<!DOCTYPE html>
<html lang="en">
<head>
<title id='Description'>Notification Letter.</title>
<link rel="icon" href="image/pacra_logo.png" type="image/png" sizes="16x16">
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
<script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../scripts/demos.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxdropdownbutton.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcolorpicker.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxwindow.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxeditor.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxtooltip.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcheckbox.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function () {
$('#editor1').jqxEditor({tools: 'bold italic underline | left center right'
});
$('#editor2').jqxEditor({tools: 'bold italic underline | left center right'
});
$('#editor3').jqxEditor({tools: 'bold italic underline | left center right'
});
$('#editor4').jqxEditor({
});
$('#editor5').jqxEditor({tools: 'bold italic underline | left center right'
});
$('#editor6').jqxEditor({
});
$('#editor7').jqxEditor({tools: 'bold italic underline | left center right'
});
$('#editor8').jqxEditor({tools: 'bold italic underline | left center right'
});
$('#editor9').jqxEditor({tools: 'bold italic underline | left center right'
});
$('#editor10').jqxEditor({tools: 'bold italic underline | left center right'
});
$('#editor11').jqxEditor({
});
});
</script>
<div style="width: 30%; float:" contenteditable="true" id="editor1">
<p> NL FY 15-147 (PSO-040515) </p>
</div>
</div>
<div style="clear: both;"></div>
<div style="margin-top: 10px; width: 800px; text-align:justify; font-family:'Times New Roman', Times, serif; font-size:14px" contenteditable="true" id="editor6">
<p>This has reference to our communication and discussion with you and your team regarding rating of Pakistan State Oil Company Limited (PSO). We appreciate that PSO management has been forthcoming in providing all the requisite information. This has enabled PACRA in forming the right ration opinion.</p>
</div>
答案 0 :(得分:0)
<强> HTML 强>
<!DOCTYPE html>
<html lang="en">
<head>
<title id='Description'>Notification Letter.</title>
<link rel="icon" href="image/pacra_logo.png" type="image/png" sizes="16x16">
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
<script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../scripts/demos.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxdropdownbutton.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcolorpicker.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxwindow.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxeditor.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxtooltip.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcheckbox.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function () {
$('#editor1').jqxEditor({tools: 'bold italic underline | left center right'
});
$('#editor2').jqxEditor({tools: 'bold italic underline | left center right'
});
$('#editor3').jqxEditor({tools: 'bold italic underline | left center right'
});
$('#editor4').jqxEditor({
});
$('#editor5').jqxEditor({tools: 'bold italic underline | left center right'
});
$('#editor6').jqxEditor({
});
$('#editor7').jqxEditor({tools: 'bold italic underline | left center right'
});
$('#editor8').jqxEditor({tools: 'bold italic underline | left center right'
});
$('#editor9').jqxEditor({tools: 'bold italic underline | left center right'
});
$('#editor10').jqxEditor({tools: 'bold italic underline | left center right'
});
$('#editor11').jqxEditor({
});
});
</script>
<script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.ajax({
url: "process.php",
data:{data:$("#editor6").html()},
success: function(result){
alert("success");
}
});
});
});
</script>
</script>
<div style="width: 30%; float:" contenteditable="true" id="editor1">
<p> NL FY 15-147 (PSO-040515) </p>
</div>
</div>
<div style="clear: both;"></div>
<div style="margin-top: 10px; width: 800px; text-align:justify; font-family:'Times New Roman', Times, serif; font-size:14px" contenteditable="true" id="editor6">
<p>This has reference to our communication and discussion with you and your team regarding rating of Pakistan State Oil Company Limited (PSO). We appreciate that PSO management has been forthcoming in providing all the requisite information. This has enabled PACRA in forming the right ration opinion.</p>
</div>
保存此
答案 1 :(得分:0)
你应该编写一个jQuery AJAX来发送数据到PHP文件(考虑到你可以使用Javascript / jQuery获取文本):
<强>的jQuery 强>
// put this in your <Script> in $(document).ready(... section
// This Line Gets The Text Of The Editor
var textVariable = $("#editor6 p").text();
// This Part Sends The Data To The Defined PHP File And Returns The Result
$.post("TARGET_PHP_FILE.php", {TypedText: textVariable}, function(data, status){
// Do Something With The Response
// data: every thing that prints on php file
// status: HTTP Response Code
// For more Info: http://www.w3schools.com/jquery/ajax_post.asp
});
<强> PHP 强>
// Your Text Is Available Like This:
$text = $_POST['TypedText'];
// Then You Can Store It In Database Like This:
if ($db = mysqli_connect($host, $user, $pass)) {
// Connected to the server
if ($select = mysqli_select_db($db, "DATABASE_NAME")) {
// Selected the database
$query = "Your Query";
if ($result = mysqli_query($db, $query)) {
// Query sent
if (mysqli_affected_rows($db)) {
echo "Done";
mysqli_close($db);
}else{
echo "Fail";
mysqli_close($db);
}
}else{
echo "Query Not Sent";
}
}else{
echo "Selection Failed";
}
}else{
echo "Connection Failed";
}