gpt4 book ai didi

php - if语句放错地方了

转载 作者:行者123 更新时间:2023-11-29 13:34:05 25 4
gpt4 key购买 nike

请你帮忙?我通过搜索表单和输出结果运行查询,但它没有按应有的方式显示?对 php 还很陌生,所以请原谅我的代码......

需要的结果。如果搜索返回,我想要两件事之一。要显示受雇者: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);
}

最佳答案

您在 if (mysql_num_rows($sql) > 0 ) { 上方放置了一个额外的左花括号 {更正的代码:

<?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);
}

关于php - if语句放错地方了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19003084/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com