请你帮忙?我通过搜索表单运行查询并输出结果,但它没有按应有的方式显示?对 php 还是很陌生,所以如果我的代码是……请原谅。
需要的结果。如果 te search 返回我想要两件事之一。要显示受雇者:xxx 或当前未受雇:
<?php
if ($_REQUEST['submit']) {
$term = $_POST['term'];
$row ['employerid'] == $user_data ['user_id'];
$XX = "<br><br><div class='messagebox'><h2> <center> Oops! </h2> <p>We were only to retrieve a partial record on <strong>$term</strong> you have entered. Please make use of our contact form if you would like us to get you your reference. Be sure to enter the three required fields. <a href='Mailforms/refrequest.php' class='lightbox'>Click Here!</a> or to validate the id <a href='idverification.php'> Click here</a></p>
<br />
</div>";
$sql = mysql_query("select * from ref_employees where `idnumber`= '$term'")
or die('Error in query : $sql. ' .mysql_error());
{
if (mysql_num_rows($sql) > 0 )
{
while ($row = mysql_fetch_array($sql)){
if ($row ['employed'] == '1') {
echo '<h4>Currently Employed By : '.$row['companyname'];
echo '</h4> ';}
if ($row ['employed'] == '0') {
echo '<h4>Not Currently employed : '.$row['companyname'];
echo '</h4> ';}
echo '<h4> ID : '.$row['idnumber'] ;
echo '<br> First Name : '.$row['firstname'];
echo '<br> Last Name : '.$row['lastname'];
echo '<br> Gender : '.$row['gender'];
echo ' </h4>';
echo '<br />';
echo '<h2>Some Additional Options</h2>';
echo '<br />';
}
}
else
{
print ("$XX");
}
mysql_free_result($sql);
mysql_close($connection);
}