Reputation: 125
I am a beginner when it comes to php.... I have the following:
I am not sure if it is my if statement expressed wrong or just at the wrong place. I want it not to show the records when the companyname == the businessname! Please advise?
if (mysql_num_rows($sql) > 0 && **($row['companyname'] == $user_data['businessname'])** )
{
while ($row = mysql_fetch_array($sql)){
if (($employed =='1')){
echo '<h4> ID : '.$row['idnumber'] ;
echo '<br> First Name : '.$row['firstname'];
echo '<br> Last Name : '.$row['lastname'];
echo '<br> Reference 1 : '.$row['ref1'];
echo '<br> Reference 2 : '.$row['ref2'];
echo '<br> Reference 3 : '.$row['ref3'];
echo '<br> Gender : '.$row['gender'];
echo '<br> Company : '.$row['companyname'];
echo ' </h4>';
echo '<br />';
echo '<h2>Some Additional Options</h2>';
echo '<br />';
include 'includes/admenu.php';
}
}
}
else
{
print ("$XX");
}
Upvotes: 0
Views: 71
Reputation: 76666
The $row
variable doesn't exist outside your loop, so it's pointless trying to use it in the if
statement. You need to move it inside the loop, like so:
while ($row = mysql_fetch_array($sql))
{
if ( ($employed =='1') && ($row['companyname'] == $user_data['businessname']) )
{
// code ...
}
}
I want it not to show the records when the companyname == the businessname!Move the statement inside your loop:
I'm not actually sure if you're trying to display when companyname == the businessname
or companyname != the businessname
. Either way, change your if
condition accordingly and it should work.
Upvotes: 4