bangkokrefa.blogg.se

Php if else statement with post data
Php if else statement with post data








php if else statement with post data
  1. #Php if else statement with post data how to
  2. #Php if else statement with post data software
  3. #Php if else statement with post data code

#Php if else statement with post data code

This code is untested but should do what you want. $post_tag will be empty if there is nothing with this tag, and $post_cat gets what you want. I'm assuming your two $post_cat and $post_tag searches do what you want for these two cases - i.e. What you can do is test have_posts before you start the while loop, and then keep which ever query you want in a new variable. ELSEIF is used to attach a second IF condition with the previous IF so that if the previous IF is false the code will check the next IF.

php if else statement with post data

You can't start it inside one if then end it somewhere else (although that would be nice!) The PHP while command doesn't work like that, it needs to start and end in the same code block. While($catquery->have_posts()) : $catquery->the_post() While($tagquery->have_posts()) : $tagquery->the_post() If there is no ''event' tag, only the recent post of Party category will display If the post with category Party has tag which is 'event', it is the one that will display Since the first if statement’s condition is satisfied, it executes its statements. However, the second if statement in the example above, has an else built onto it. MARK YOUR POST AS SOLVED If your post has been solved, mark it as so by clicking Flair -> Solved.įor inline code, use `backticks` to look like this.įor a moderate amount of code, put it on separate lines, and prepend each line with four spaces, like this: įor a lot of code, use PasteBin or something similar.I want to filter my post based on category (Party) So, if you had an if statement that was below another if statement, the first if statement would be separate from the second if statement just like the example above. Please become familiar with these guidelines as we, as moderators, will use them to remove content that we deem to violate these guidelines. Self-promotion and/or linkdropping rules Our community adheres to the Reddit Self-Promotion Guidelines.

#Php if else statement with post data software

No malicious/illegal software Don't ask for help with phishing software, for example. Don't take the provided answers away from them! 6. If the condition is True then it executes the True part of the statements, otherwise, it will execute else part of the statements. Don't delete an answered post People may be searching to solve a similar problem in the future. Use a meaningful title Titles like: "PHP Help", "Help please", "Beginner question", or "I need some help with resolving this issue" are not good and not meaningful. Actively participate when you make a post by answering questions and sharing solutions. Like else, it extends an if statement to execute a different statement in case the original if expression evaluates to false. Participate Posts that are only intended to get others to solve your problem add nothing to the community. Language Reference Control Structures Change language: Submit a Pull Request Report a Bug elseif/else if (PHP 4, PHP 5, PHP 7, PHP 8) elseif, as its name suggests, is a combination of if and else. If you believe someone is wrong, kindly inform them why you think so. When supplying code, preferably use PasteBin or similar.

#Php if else statement with post data how to

Help us help you! Provide details about your question and be as specific as possible. In this tutorial youll learn how to write decision-making code using if.else.elseif statements in PHP. In this case you can use the If Else Statement, so if name does not equal Asim it is false, so execute the Else Statement. If you use three of them, PHP will compare both value and. If someone answers your question, please mark your post as SOLVED.ġ. If statements contain statements that are only executed when the condition is satisfied. The difference is if you use two equal signs, PHP will only look to see if the values are identical. Review our github to see if your question already has a great answer. Post specific problems or questions you have about PHP or your code.










Php if else statement with post data