我想有一个单独的字段,我可以在其中将数据库中的时间添加到与日期相同的单元格中。
一切正常,但数据库中的时间不会改变。我该如何解决这个问题?
议程.html:
<!---------------------------------------------------------
<! HTML/PHP
<!----------------------------------------------------------->
<title>Blackboks • Agenda</title>
<div id="header">
<div class="header-text">Agenda</div>
<body class="modal-header">
<button id="b1" class="btn btn-primary "><i class="fa fa-plus-square"> </i>Nieuwe afspraak</button>
<form class="form-inline">
<div id="d1" title="Nieuwe afspraak" style="display: none">
<div class="control-group">
<label class="control-label">Title:</label>
<div class="controls">
<input type="text" name="username" placeholder="Titel" id="name"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Beschrijving:</label>
<div class="controls">
<input type="text" name="userdesc" placeholder="Beschrijving" id="desc"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Starttijd:</label>
<div class="controls">
<input type="text" name="userstart" placeholder="Starttijd" id="start"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Eindtijd:</label>
<div class="controls">
<input type="text" name="userend" placeholder="Eindtijd" id="end"/>
</div>
</div>
</div>
<div id="d2" title="Checking Empty..." style="display:none;">
<p>Vul alstublieft wat in....!</p>
</div>
</div>
<div id="content">
<div id="table-row">
<!-- <div class="header_title" style="margin-bottom: 10px;">Agenda</div> -->
<div class="agenda">
<html>
<head>
<link href='<?=base_url();?>testcalendar/css/fullcalendar.css' rel='stylesheet' />
<script src='<?=base_url();?>testcalendar/js/jquery-1.9.1.min.js'></script>
<script src='<?=base_url();?>testcalendar/js/jquery-ui-1.10.2.custom.min.js'></script>
<script src='<?=base_url();?>testcalendar/js/fullcalendar.min.js'></script>
<script src='<?=base_url();?>testcalendar/js/fullcalendarextern.js'></script>
<script src='<?=base_url();?>testcalendar/js/nieuweafspraak.js'></script>
<link href="<?=base_url();?>testcalendar/assets/css/jquery-ui-1.10.0.custom.css" rel="stylesheet" type="text/css" />
<style>
body {
margin-top: 40px;
}
#calendar {
width: 900px;
margin: 0 auto;
}
</style>
</head>
<body>
<div id='calendar'></div>
</body>
</html>
</div>
</div>
Nieuwe afspraak.js:
$(function () {
// Dialog Open
$("#d1").dialog({
autoOpen: false,
height: 'auto',
width: 'auto',
modal: true,
closeOnEscape:true,
resizable:false,
show:'fade',
buttons: {
"Add": function() {
var id = $("#id").val(),
name = $('#name').val(),
desc = $('#desc').val(),
age = $('#age').val(),
end = $('#end').val();
if(id=='' || name=='' || desc=='' || age=='' || end=='')
{
//alert("Please do not empty....!",title="Hello");
$("#d2").dialog("open");
$("#d2").dialog({
buttons:{
"OK":function(){
$(this).dialog("close");
$("#id:first").focus();
}
}
});
exit;
}//End if statement
$.post('../testcalendar/db/process.php',{
user_id: id, user_name: name, user_desc: desc, user_age: age, user_end: end, action:'joined'
}); var nTime = 1 * 50;
window.setTimeout("location.reload()", nTime);//End Post
$("#id").val('');
$("#name").val('');
$("#desc").val('');
$("#age").val('');
$("#end").val('');
$(this).dialog("close");
},
"Cancel": function() {
$("#id").val('');
$("#name").val('');
$("#desc").val('');
$("#age").val('');
$("#end").val('');
$(this).dialog("close");
}
}
});
$("#d2").dialog({
autoOpen: false,
height: 'auto',
width: 'auto',
modal: true,
closeOnEscape:true,
resizable:false,
show:'fade',
buttons: {
"Ok": function() { $(this).dialog("close"); }
}
});
$("#b1").click(function(){
$("#d1").dialog("open");
});
$("#age").datepicker({ dateFormat: 'yy-mm-dd' });
$("#end").datepicker({ dateFormat: 'yy-mm-dd' });
});
工艺.php:
<?php
//include db configuration file
include 'connection.php';
function user_joined($user_name,$user_desc, $user_start,$user_starttime $user_end){
$q = "INSERT INTO evenement (title,description,start,end) VALUES
('".$user_name."','".$user_desc."','".$user_start.$user_starttime."','".$user_end."')";
mysql_query($q);
}
if(isset($_POST['user_name'],$_POST['user_desc'],$_POST['user_start','user_starttime'],$_POST['user_end'],$_POST['action'])){
$user_name=$_POST['user_name'];
$user_desc=$_POST['user_desc'];
$user_start=$_POST['user_start','user_starttime'];
$user_end=$_POST['user_end'];
$action=$_POST['action'];
if ($action=='joined'){
user_joined($user_name, $user_desc, $user_start, $user_starttime, $user_end);
}
}
/*if ( (isset($_POST["id"]) && strlen($_POST["id"]) >= 3 && strlen($_POST["id"]) <= 60) &&
(isset($_POST["name"]) && strlen($_POST["name"]) >= 3 && strlen($_POST["name"]) <= 50) &&
(isset($_POST["age"]) && strlen($_POST["age"]) >= 3 && strlen($_POST["age"]) <= 40) )
{ //check $_POST["name"] and $_POST["address"] and $_POST["city"] are not empty
$id = $_POST["id"];
$name = $_POST["name"];
$age = $_POST["age"];
$q = "INSERT INTO tbltest ( id, name, age) VALUES
('".$id."','".$name."','".$age."')";
mysql_query($q);
}*/
?>
连接.php:
<?php
$db_host = "localhost";
// Place the username for the MySQL database here
$db_username = "root";
// Place the password for the MySQL database here
$db_pass = "root";
// Place the name for the MySQL database here
$db_name = "calendar";
// Run the actual connection here
mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql");
mysql_select_db("$db_name") or die ("no database");
?>
我不确定您可以在数据库脚本中传递这样的数组。
如果我很清楚你想连接日期和时间,所以试试这个:
$user_start=$_POST['user_start']." ".$_POST['user_starttime'];