我有一個名爲item_request的表,它有兩個名爲projectmanager和createddate的時間戳格式爲2012-09-11 17:46:25的表格。從數據庫中提取日期格式不分離
現在我想調用這兩個字段的另一種形式,它計數用戶在兩個不同的日期之間的條目。日期字段從timestamp中獲取。使用此表單im通過datetime選擇器發送值,格式爲10-但是databse中的值是不同格式的,im發送的值是不同的格式。有沒有可能plzzz幫助我們。
這裏是我的表單代碼:
<?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> </td>
<td>
<input type="submit" name="submit" id="submit" value="Submit" onClick="return formvalidate();"/>
</td>
</tr>
<tr>
<td> </td>
<td> </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>
你是說你想要一種方法將日期從MM-DD-YYYY轉換爲DD-MM-YYYY? – George
或者對不起,MM-DD-YYYY H:M:S到DD-MM-YYYY H:M:S? – George
沒有傢伙我在我的表中的時間戳格式的日期爲2012-09-11 17:46:25。我想在另一個顯示兩個不同日期之間記錄的頁面中獲取這個值。所以我做一個表格,並在其中我有一個日期時間選擇器,如上所示,以10-12-1988格式發送請求。 所以時間戳值和我的值不匹配atall.how我可以實現它plzzz幫助我。 –