简体   繁体   English

PHP,Mysql日历

[英]PHP, Mysql Calendar

I have created a calendar which is connected to mysql. 我创建了一个连接到mysql的日历。 The calendar searchs mysql and shows the number of employees on timeoff. 日历搜索mysql并显示超时的员工人数。 There are several managers for a variety of employees. 有几位经理为各种员工服务。 I created a searchterm box at which the manager can type there name and the code will query the database specific to the managers name (essentially only showing that managers employees instead of the whole company). 我创建了一个搜索词框,经理可以在其中键入名称,并且代码将查询特定于经理名称的数据库(实际上仅显示经理的雇员,而不是整个公司)。 The number of employess on time off are shown inside the calendar as a link and the total number for that specific day. 日历内以链接的形式显示了下班时间的雇员人数以及该天的总数。 Once clicked it then shows the employee names associated with the day. 单击后,将显示与当天相关的员工姓名。 The problem im having is once the manager clicks onto the link, it automatically defaults to all employees instead of the ones specific to the manager. 问题是,一旦经理单击链接,它将自动默认为所有雇员,而不是特定于经理的雇员。 The managers search term is getting dropped and the code is defaulting back as if nothing was entered. 经理的搜索字词被删除,并且代码默认返回,就像什么都没有输入一样。 My question is how I can reuse that searchterm over and over again until other wise directed. 我的问题是,如何在其他明智指示之前一遍又一遍地重复使用该搜索词。

$searchTerm = trim($_GET['keyname']);


if( $searchTerm != 'All Drivers' && $searchTerm != '')

{
$sqlEvent2 = mysql_query("select * FROM timeoff_365_days where (DM = '$searchTerm' or FM = '$searchTerm' or region ='$searchTerm' or location ='$searchTerm') and  TimeOffDate = '".$year."-".$month."-".$i."'"); 
$num_rows = mysql_num_rows($sqlEvent2);

echo '<div id="button">';
echo "<a  href='".$_SERVER['PHP_SELF']."?month=".$monthstring."&day=".$i."&year=".$year. "&v=false  ' >".$num_rows."</a></td>"; 
echo '</div>';


}
else{






 $sqlEvent = mysql_query( "select * FROM timeoff_365_days where TimeOffDate = '".$year."-".$month."-".$i."'"  );
if (!$sqlEvent) {
    echo 'Could not run query: ' . mysql_error();
    exit;
}



$num_rows = mysql_num_rows($sqlEvent);
echo '<div id="button">';
echo "<a  href='".$_SERVER['PHP_SELF']."?month=".$monthstring."&day=".$i."&year=".$year."&v=true' >".$num_rows."</a></td>"; 
echo '</div>'; 

 $sqlEvent = mysql_query( "select * FROM timeoff_365_days where TimeOffDate = '".$year."-".$month."-".$i."'"  );
if (!$sqlEvent) {
    echo 'Could not run query: ' . mysql_error();
    exit;
}



$num_rows = mysql_num_rows($sqlEvent);
echo '<div id="button">';
echo "<a  href='".$_SERVER['PHP_SELF']."?month=".$monthstring."&day=".$i."&year=".$year."&v=true' >".$num_rows."</a></td>"; 
echo '</div>'; 

}

} 

echo "<tr>";
echo"</table>";
?>
<div class="accordion vertical">
<ul>
<li> 
<input type="radio" id="radio-3" name="radio-accordion" />
            <label for="radio-3">Time Off by Driver Code</label>
            <div class="content">




<?php
if(($_GET['v']==false)) {
$sqlEvent2 = "select * FROM timeoff_365_days where (DM = '$searchTerm' or FM = '$searchTerm' or region ='$searchTerm'or location ='$searchTerm') and TimeOffDate ='".$year."/".$month."/".$day."'";
$resultEvents2 = mysql_query($sqlEvent2);

while ($events2 = mysql_fetch_array($resultEvents2)){
echo $events2['DriverCode']."-";
echo $events2['Unit']."</br>";
}
}
else {
echo "";

}
?>

<?php
echo "<tr >";
var_dump($searchTerm);


if(isset($_GET['v'])) {
$sqlEvent = "select * FROM timeoff_365_days where TimeOffDate ='".$year."/".$month."/".$day."'";
$resultEvents = mysql_query($sqlEvent);

while ($events = mysql_fetch_array($resultEvents)){
echo $events['DriverCode']."-";
echo $events['Unit']."</br>";
}
}
else {
echo "";
}
echo "<tr>"; 

var_dump($searchTerm);

?>

使用$ _GET获取它,因此可以在domain.com/index.php?url=search中找到它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM