<form class="form-inline" id="form1" method="post" role="form" action="">
<div class="from-group">
<label for="usr">Search Here</label>
<input id="search" name="search" class="form-control" placeholder="Enter the First Name">
<input type="submit" class="btn btn-success" name="SearchSubmit" value="GO" />
</div>
<div>
<a class="btn btn-primary" href="logout.php">LOGOUT</a>
</div>
</form>
<?php var_dump($_POST['SearchSubmit']); ?>
<table class="table text-info">
<tr>
<th class="text-center">First Name</th>
<th class="text-center">Last Name</th>
<th class="text-center">Date of Birth</th>
<th class="text-center">Address</th>
<th class="text-center">Last Passout Standard</th>
<th class="text-center">Last Passout Percentage</th>
<th class="text-center">Last Passout Year</th>
</tr>
<tbody id="log"></tbody>
</table>
<script type="text/javascript" language="javascript">
<?php if($_POST['SearchSubmit']){ ?>
$('document').ready(function() {
$('#log').load('searchresult.php');
});
//$('#log').load('searchresult.php');
<?php } ?>
$('document').ready(function() {
$('#log').load('studentList.php');
});
//$('#log').load('studentList.php');
</script>
上面提到的是我的代码,但我无法在我当前的php页面中加载任何日志文件。 我也打印$_POST['SearchSubmit']
我得到的是空值。 我只想得到,如果搜索框被填充,所以searchresult将被加载,否则studentList将被加载。 请帮忙解决这个问题。
DFK你正在使用JavaScript混合PHP的,为什么呢? – madalinivascu
你的php if语句缺少php开启和关闭标记 –
ohh我明白了,我是一个在PHP中的开始,所以我犯了这个错误。 –