【发布时间】:2016-09-09 13:04:35
【问题描述】:
我是创建网络服务的新手。我在 XML 中创建了一个 Web 服务,如下所示:
<?php
$con = mysqli_connect('localhost','root','','crmap');
$query1="SELECT * FROM `crm_salesabsent_logsheet` WHERE `ab_date`=CURRENT_DATE()";
$res=mysqli_query($con,$query1) or die(mysqli_error($con));
$data= array();
if(mysqli_num_rows($res)){
while($row1=mysqli_fetch_assoc($res)){
$data[] = array('row1'=>$row1);
}
}
header('Content-type: text/xml');
echo '<posts>';
foreach($data as $index => $row1) {
if(is_array($row1)) {
foreach($row1 as $key => $value) {
echo '<',$key,'>';
if(is_array($value)) {
foreach($value as $tag => $val) {
echo '<',$tag,'>',htmlentities($val),'</',$tag,'>';
}
}
echo '</',$key,'>';
}
}
}
echo '</posts>';
?>
我没有在日期中传递任何参数,因为我将 Current_Date() 作为默认值。现在,我希望用户选择他们想要的日期。我想将日期作为参数传递并根据输入的日期显示查询结果。这是我试图在 MySQL 查询中将日期作为参数传递的 Html 代码
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>/title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<style>
.dt{}
</style>
<script>
$(document).on('focus', '.dt', function() {$(this).datepicker({ dateFormat : 'dd-mm-yy'});});
</script>
</head>
<body>
<form name="log" method="get">
<table>
<tr>
<th>Select Date</th><td><input name="date" id="date" value="" class="dt"></td>
<tr><td><input type="submit" name="post" id="post" value="Submit"></td></tr>
</tr>
</table>
</form>
</body>
</html>
但我无法这样做,因为我收到错误消息。帮助和解决方案将不胜感激。 谢谢
【问题讨论】:
标签: php html mysql xml web-services