I have this as my syntax, and my issue is that if both $employee and $saleDate are set the where clause is added as expected. However, if only $employee OR $saleDate are set, then the where clause is never added to the query. What is the proper way to write this syntax so that the appropriate where clauses is…
Tag: if-statement
php $image = get_field( ‘image’ ) // if // else
I need an inquiry if there is no image that an alternative image is used. the crazy thing is that it works on four out of 18 images. I think I have an error in the “else query” somewhere. Because if I swap the defalut image with the actual product image, then it works .. but of course that is
Returning Optional Values based on Database Value
I’m trying to return a SVG based on the value 1,2 or 3 from my database column called foo_options. IF 1 return Green SVG IF 2 return Orange SVG IF 3 return Red SVG foo_options has the value of 3 in …
Syntax for multiple “or” statements to set a CSS class
I’m quite new to PHP. The problem statement is, I need to insert a CSS class into the nav on specific pages. Here’s the way I have it now: It works but it feels messy. I’m going to continue to research it (perhaps a switch statement is better?). Is there a cleaner way of doing this? Answer I…
Header issue does not load the right one
Hi so i have couple of headers that have different menus for different users and my code is if (isset($_SESSION[“role”])== “engineer” or isset($_SESSION[“role”])!=”…
Displaying icons using php IF
Just wondering, I’m creating a multi-vendor website. So far it has all been going well, however we have a need to display icons as badges if a field contains data. Here is an example of the code: &…
how to add if current date is before a certain date condition as an if-statement parameter
I have a WordPress site and I have written a filter: function wc_add_string_to_price_newline( $price, $product ) { $product_id = $product->get_id(); if ($product_id == ‘1190’) { $…
PHP Redirect Not Working When In A Nested IF Statement
I’ve looked at several of the “PHP redirect not working ……” posts, but I haven’t had any luck figuring out what is going on with my problem. The code below always goes to teacherActivity_2.php …
Table query, select data from table1, but only if user settings in table2 is set to a specific value
I got a problem with this query. Not sure what this type of problem is called, so have problems searching for a solution 🙁 I got two tables: configurations, users Lets say the tables looks like …
else, elseif,else statement is not working with fwrite in php
i want to write expiry date in a text file with respect to condition but when i echo in browser, it works fine but at the same time it is not writing in text file. Here is my code: condition is based …