Home > Blockchain >  Struggling to hide a Div based on a database table entry using PHP
Struggling to hide a Div based on a database table entry using PHP

Time:02-08

I have been trying to select the database table check if it is a 1 or a zero and then display the div based on this, I am really confused as to where I am going wrong and maybe you guys could help..

This is my code snippet

<?php 
$query_da = mysql_query("SELECT * FROM tragency WHERE DualRecruiter = '{$row['DualRecruiter']}' AND AgencyID = '{$row['AgencyID']}'");

    if ($row['AgencyID'] = 20 and ($row['DualRecruiter'] = 1 )) ?>
         <tr>
            <td colspan="3">
                <div style="margin-top: 5px; width: 100%">
                    <div>
                        <span>Apply directly by entering your email address below:</span>
                    </div>
                    <div style="margin-top: 5px">
                        <form id="form_jobspec" method="post" action="email_candidate_on_job.php">
                            <div >
                                <div >
                                    <input  name="email">
                                    <input hidden name="joblistingName" value="<?php echo $row['Name'] ?>">
                                    <input hidden name="consultant" value="<?php echo $row['Consultant'] ?>">
                                    <input hidden name="jobspecsId" value="<?php echo $row['JobspecsId'] ?>">
                                    <input hidden name="clientID" value="<?php echo $row['ClientID'] ?>">
                                
                                
                                    <button type="submit" >Apply</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </td>
        </tr> 
    </table>

CodePudding user response:

if ($row['AgencyID'] = 20 and ($row['DualRecruiter'] = 1 )) will acte on the first line after it. And theres error on it.

you should do something like that

<?php 
$query_da = mysql_query("SELECT * FROM tragency WHERE DualRecruiter = '{$row['DualRecruiter']}' AND AgencyID = '{$row['AgencyID']}'");

    if ($row['AgencyID'] == 20 and ($row['DualRecruiter'] == (integer) 1 )){ ?>

all the html code needed in

    <?php } ?>

CodePudding user response:

Declaring and Conditional Verifying Is Different And uses different signs.

So Your Condition would be:

if ($row['AgencyID'] == 20 and ($row['DualRecruiter'] == 1 ))

For declaring a variable we use A single = sign.

$variable = "Hi i am a variable";

For conditions we use double ==

$is_ok = $record['enabled'] == true;

Though this doesn't check if the DATATYPES Are same. This means that:

$record['enabled'] == true;

And

$record['enabled'] == 'true';

Will Give the same results. To verify the DATATYPE as well, we use triple ===

$record['enabled'] === true; // returns true
$record['enabled'] === 'true'; // returns false

You can learn more about it here

  •  Tags:  
  • Related