jeudi 15 mars 2018

Check for null in an if loop

I am having some problems with my program. I am creating a script wich displays all the properties in the properties table in our database and one row in the table should show available or sold. it should check if the puserId is null or 1 or more

                    //Execute the Query
                         $records = mysqli_query($con, $sql);

                         while($row = mysqli_fetch_array($records)){
                             echo "<tr>";
                             echo "<td>".$row['propertyId']."</td>";
                             echo "<td>".$row['propNum']."</td>";
                             echo "<td>".$row['AptNum']."</td>";
                             echo "<td>".$row['street']."</td>";
                             if (empty(['puserId'])) {
                                $status = 'Available';
                             }else {
                                $status = 'Sold';
                             }
                             echo "<td>".$status."</td>";

When i use this it shows that all properties are sold, also the ones wich have a puserId of null. It doesn't give me any errors though.

Anybody know how i should do this?

Thanks in advance :)

Aucun commentaire:

Enregistrer un commentaire