Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从数据库中提取数据时,日期格式未分离_Php_Javascript_Mysql - Fatal编程技术网

Php 从数据库中提取数据时,日期格式未分离

Php 从数据库中提取数据时,日期格式未分离,php,javascript,mysql,Php,Javascript,Mysql,我有一个名为item_request的表,它有两个名为projectmanager和createddate的字段,时间戳格式为2012-09-11 17:46:25 现在我想用另一种形式调用这两个字段,计算两个不同日期之间的用户输入。日期字段从时间戳中提取。使用这种形式,我通过datetime picker发送值,格式为10-12-2012,但数据库中的值格式不同,发送的值格式不同。如何有可能帮我吗,伙计们 以下是我表格的代码: <?php include("config.php");

我有一个名为item_request的表,它有两个名为projectmanager和createddate的字段,时间戳格式为2012-09-11 17:46:25

现在我想用另一种形式调用这两个字段,计算两个不同日期之间的用户输入。日期字段从时间戳中提取。使用这种形式,我通过datetime picker发送值,格式为10-12-2012,但数据库中的值格式不同,发送的值格式不同。如何有可能帮我吗,伙计们

以下是我表格的代码:

<?php 
include("config.php");
ob_start();
error_reporting(0);
if(!isset($_SESSION[username]))
header("location: index.php");
if(isset($_POST[submit]))
{
$projectmanager=mysql_real_escape_string($_POST['projectmanager']);
$date=mysql_real_escape_string($_POST['date']);
$dateexp = explode("-",$date);
$date = mysql_real_escape_string($dateexp[0]."/".$dateexp[1]."/".$dateexp[2]);


$date1=mysql_real_escape_string($_POST['date1']);
$dateexp1 = explode("-",$date1);
$date1 = mysql_real_escape_string($dateexp1[0]."/".$dateexp1[1]."/".$dateexp1[2]);

echo $queryuser= "select * from  item_request where projectmanager=$projectmanager AND (requireddate>=$date AND requireddate<=$date1)";

}
?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Project Managers Registrarion</title>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<script language="javascript" type="text/javascript" src="js/datetimepicker.js">

//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
//For this script, visit http://www.javascriptkit.com

</script>

</head>
<body>

<div class="container">
  <div class="header"><a href="#"><img src="images/cherry-new.jpg" width="79" height="93" /></a> 
    <!-- end .header --></div>
<?php include("rightMenu.php");?>
  <div class="content">
    <h1>PR Count</h1>
    <div style="padding:10px 0px; text-align:center; color:#990000;">
    </div>
    <form action="" method="post" name="loginform">


<table width="100%" border="0" cellspacing="2" cellpadding="2">
  <tr>
  <td>Project Managers</td>
           <td><select name="projectmanager" style="width:145px;" id="projectmanager" onChange="showUser(this.options[this.selectedIndex].id)">
               <option value="">Select</option>
               <?php $queryuser= "select * from  projectmanagers";
              $fetuser1user = mysql_query($queryuser);
              while($fetuser = mysql_fetch_array($fetuser1user)){
        ?>
               <option id="<?php echo $fetuser['id']?>" value="<?php echo $fetuser['id']?>"><?php echo $fetuser['projectmanager']?></option>
               <?php }
        ?>
             </select></td>
     </tr>
  <tr>
    <td>Date From</td>
    <td>
      <input id="date" type="text" size="20" name="date"  /><a href="javascript:NewCal('date','ddmmyyyy')"><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a></td>
  </tr>
  <tr>
    <td>Date To</td>
    <td>
      <input id="date1" type="text" size="20" name="date1"><a href="javascript:NewCal('date1','ddmmyyyy')"><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
      <input type="submit" name="submit" id="submit" value="Submit" onClick="return formvalidate();"/>
 </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>


       <table width="100%" border="1"><tr>
                <td width="18%" valign="middle" class="tableheading">PI.No.</td>
                <td width="18%" valign="middle" class="tableheading">Project Manager</td>
                <td width="18%" valign="middle" class="tableheading">Date Created</td>
                <td width="15%" valign="middle" class="tableheading">Action</td>
                </tr>
                 <?php 
                 // to print the records
                $select = "select * from item_request";
                $query1 = mysql_query($select);  
                 while($value = mysql_fetch_array($query1)){ ?>

                <tr>
                <td class="tabletext"><?php echo $value[id];?></td>
                <td class="tabletext"><?php echo $value[projectmanager];?></td>
                <td class="tabletext"><?php echo $value[datefrom];?></td>               
                <td class="tabletext"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?id=<?php echo $value[id];?>&cmd=edit"><img src="images/edit.png" width="25" height="25" border="0" title="Edit" /></a>
               <a href="<?php echo $_SERVER['PHP_SELF']; ?>?id=<?php  echo $value[id];?>&cmd=delete" onclick="return confirm('Are you sure you want to delete <?php  echo $value[projectmanager];?>?')"><img src="images/deleteBtn.png" width="25" height="25" border="0" title="Edit" /></a></td>
              </tr><?php }?>
                </table>
    </form>


    <!-- end .content --></div>
  <?php include("footer.php");?>
  <!-- end .container --></div>
</body>
</html>

项目经理注册
//日期时间选择器脚本-作者:吴腾勇http://www.rainforestnet.com
//JavaScript工具包中的脚本(http://www.javascriptkit.com)
//有关此脚本,请访问http://www.javascriptkit.com
公关计数
项目经理
挑选
从
日期
不。
项目经理
创建日期
行动

替换此函数调用

javascript:NewCal('date','ddmmyyyy');
用这个

javascript:NewCal('date','ddmmyyyy',true,24);

希望能有所帮助。

你是说你想要一种将日期从MM-DD-YYYY转换为DD-MM-YYYY的方法吗?或者,对不起,从MM-DD-YYYY H:M:S转换为DD-MM-YYYY H:M:S?不,老兄,我的表中的日期是时间戳格式的2012-09-11 17:46:25。我想在另一个页面中获取这个值,显示两个不同日期之间的记录。因此,我制作了一个表单,其中有一个日期时间选择器,如上图所示,它以10-12-1988的格式发送请求。因此,时间戳值和我的值与atall不匹配。我如何实现它?plzzz帮助我。因此,您希望表单中的日期转换为与数据库中相同的格式?你在那里给出的是DD-MM-YYYY或MM-DD-YYYY格式的“10-12-1988”吗?在数据库中,我有一个有时间的日期值,我发送的值只有日期,所以我如何匹配它。thnks很多,兄弟。它对我很有用……thnks很多,谢谢你的帮助……:)上帝保佑你……)