douchiwan1503 2014-11-20 19:01
浏览 72
已采纳

PHP,Mysql日历

I have created a calendar which is connected to mysql. The calendar searchs mysql and shows the number of employees on timeoff. 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);

?>
  • 写回答

1条回答 默认 最新

  • dqrsceg6279196 2014-11-20 19:09
    关注

    GET it with $_GET, so do it in the url with domain.com/index.php?search=asddf

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么