在下面的代码中,当我执行它时,它不显示任何结果。但我没有在if-else条件下放置任何结果。实际结果:textbox,提交按钮,没有结果。我预期的结果是一个文本框,按钮应该显示,而不是没有results.With没有搜索数据它显示没有reults.So任何人帮助我。else语句显示
<form action="<?php echo site_url('search1_site/index');?>" method = "post">
<input type="text" name = "keyword" />
<input type="submit" id="opn" value = "Search" />
</form>
<?php
if($results){
?> <div id='hideme'>
CLOSE<a href='#' class='close_notification' title='Click to Close'>
<img src="<?php echo base_url('img/close.png'); ?>" width="15" height="15" alt="Close" onClick="hide('hideme')"/>
</a> <div style="background:#FFFFFF; width: 500px; height: 500px; position: absolute; left: 50%; top: 50%; margin-left: -100px; margin-top: -100px" id="modal" >
<table class="display2 table table-bordered table-striped">
<tr>
<th>course_code</th>
<th>course name</th>
</tr>
<tr><?php
foreach ($results as $row) {
?>
<td><?php echo $row->course_code;?></td>
<td><?php echo $row->course_name;?></td>
</tr>
<?php
}
}else{
echo "no results";
}
?>
</table></div></div>
<script>
$('a.modal').bind('click', function(event) {
event.preventDefault();
$('#modal').fadeIn(10);
});
function hide(obj) {
var el = document.getElementById(obj);
el.style.display = 'none';
}
</script>
没有搜索不显示任何结果@Dipesh帕尔马 – moses
@moses确保您正在查询数据库以显示默认数据...在搜索记录之前.. –