[英]logical error in last visited page(COOKIE) and current search page in php
I have a page ( index.php
) where i display latest events fetched from db and a search box on the top of page, if someone search any event then all events regarding search displayed with name and link on page . 我有一个页面( index.php
),其中显示了从db获取的最新事件,并且在页面顶部显示了一个搜索框,如果有人搜索任何事件,那么所有与搜索有关的事件都会在页面上显示名称和链接。 now what i need 现在我需要
if we search and that is not found then display "NO event found" and request to search again. 如果我们搜索并且找不到,则显示“未找到事件”,并请求再次搜索。
currently point 2 and point 4 is covered successfully, but point 3 is not done, please suggest my logical conditions in proper way and also suggest what do i do for point 1 当前点2和点4已成功覆盖,但点3未完成,请以正确的方式建议我的逻辑条件,并建议我对点1的处理
below if main code of my page 下面是我页面的主要代码
<form action="<?=$_SERVER['PHP_SELF'];?>" method="get" accept-charset="utf-8">
<input type="text" name="keyword" id="keyword" placeholder="Search for Event" value="">
<input type="submit" name="submit" id="submit" value="Search" >
</form>
if(empty($_GET['keyword']) && !isset($_SERVER['HTTP_REFERER'])) {
if(!empty($_COOKIE['LAST_EVENT_ID'])) { ?>
<div class="module list">
<ul id="people">
<li>
<a href="eventinfo.php?evt_id=<?=$_COOKIE['LAST_EVENT_ID'];?>&evt_name=<?=$_COOKIE['LAST_VISITED_EVENT'];?>">
<h2><?=$_COOKIE['LAST_VISITED_EVENT']?></h2>
</a>
</li>
</ul>
</div>
<?php } }
// Note count($eventItems)==4 ( by default latest events)
else if(count($eventItems) == 0) { ?>
<h2>No Events found, please Search again</h2>
<?php }
else {
?>
<div class="module list">
<ul id="people">
<?php foreach($eventItems as $value) { ?>
<li>
<a href="eventinfo.php?evt_id=<?=$value->event_id?>&evt_name=<?=$value->name?>">
<h2><?=$value->name?></h2>
</a>
</li>
<?php } ?>
</ul>
</div>
<?php ob_start();
$evt_id=$_GET['evt_id'];
$evt_name=$_GET['evt_name'];
define('SITE_PATH','http://localhost/hello_world/');
define('EVENT_ID',$evt_id);
/* first remove old cookie value */
//setcookie("LAST_EVENT_ID",EVENT_ID, time()-3600*24*7);
//setcookie("LAST_VISITED_EVENT", $evt_name, time()-3600*24*7);
setcookie("LAST_EVENT_ID", EVENT_ID, time()+3600*24*7);
setcookie("LAST_VISITED_EVENT", $evt_name, time()+3600*24*7);
if (is_dir($evt_name)){
header("location:".EVENT_PATH);
}
else{
header("location:event_detail.php");
}
?>
please tell me how do i modify my if else condition to fulfill all above points 请告诉我如何修改我的“ if if else”条件以实现上述所有要点
Thanks 谢谢
i also create truth table for all situation, plz help me to develop logic.. here is the link for truth table 我也为所有情况创建真值表,请帮助我开发逻辑..这是真值表的链接
Change 更改
<li>
<a href="eventinfo.php?evt_id=<?=$_COOKIE['LAST_EVENT_ID'];?>&evt_name=<?=$lastEventDetail['name'];?>">
<h2><?=$lastEventDetail['name']?></h2>
</a>
</li>
to 至
<li>
<a href="eventinfo.php?evt_id=<?=$_COOKIE['LAST_EVENT_ID'];?>&evt_name=<?=$_COOKIE['LAST_VISITED_EVENT'];?>">
<h2><?=$_COOKIE['LAST_VISITED_EVENT']; ?></h2>
</a>
</li>
Their is no value for $lastEventDetail['name'] .. the last event name is in the cookie 对于$ lastEventDetail ['name']来说,它们是没有值的。.最后一个事件名称在cookie中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.