if-statement

php check if date is today or greater. but only in this month

对着背影说爱祢 提交于 2019-12-25 04:57:22
问题 I have a list of dates and need to enforce a limit, which is the list to not be older than today but more than 30 days ahead of today. Is possible to modify what I have or do I need to use something like 'time' instead? if so how would I adjust what I have? $date = new DateTime($page->meta_value); if (strtotime($page->meta_value) > time()) { echo '<h2><div class="date-title">'; echo $page->post_title.' - '; echo '</div><div class="date-date">'; echo $date->format('d-m-Y').'<br/>'; echo '</div

creating new column based on rows being equal in R

早过忘川 提交于 2019-12-25 04:28:41
问题 Here is a simple question about creating a new column conditional on a row duplicate in one column matching criterion in different column. Specifically, if the row is a duplicate in column "pairs", create new column "new" based on rows in column "y" being equal/unequal. In the actual data frame I have even more conditions for other columns but my main issue is with making these conditions dependent on the rows being the same in the "pairs" column. Many thanks! pairs y new 1 1 1 1 0 1 2 1 0 2

Guess a number program with Java

妖精的绣舞 提交于 2019-12-25 04:16:12
问题 I am trying to create a program in Java in which the computer randomly guesses a number between 1-100 and allows the user to guess to the number. If the number is lower than the random number the program should say: lower! and if higher, the program should say: higher! If the user guesses the right number, it should say congratulations you guessed the right number in X amount of tries . This is what I have so far, any help would be appreciated! import java.util.Scanner; public class

How to code PHP function that displays a specific div from external file if div called by getElementById has no value?

China☆狼群 提交于 2019-12-25 04:15:10
问题 Thank you for answering my question so quickly. I did some more digging and ultimately found a solution for grabbing data from external file and specific div and posting it into another document using PHP DOMDocument. Now I'm looking to improve the code by adding an if condition that will grab data from a different div if the one called for initially by getElementById has now data. Here is the code for what I got so far. External html as source. <div id="tab1_header" class="cushycms"><h2

Java: unary if - npe

筅森魡賤 提交于 2019-12-25 03:56:08
问题 Why does this code can cause a NPE? Findbugs give me the hint, that this can occur and it does sometimes :-) Any ideas? public Integer whyAnNPE() { return 1 == 2 ? 1 : 1 == 2 ? 1 : null; } 回答1: EDIT: The code in the question wasn't present when I wrote this answer. Here's another method to make it slightly clearer: public static Integer maybeCrash(boolean crash) { return true ? (crash ? null : 1) : 0; } The important point is that we have two conditional expressions here. The inner one is of

If - else statements

﹥>﹥吖頭↗ 提交于 2019-12-25 03:34:41
问题 I am having an issue with my logic in my if else statements. String[] keywords = { "day", "What book", "office", "hour", "e-mail" }; Scanner scanner = new Scanner(System.in); String input = null; /* -end init- */ System.out.println("Welcome "); System.out.println("What's on your mind?"); do { System.out.print("> "); input = scanner.nextLine().toLowerCase(); for (String keyword : keywords) { if (input.contains(keyword)) { parseFile(keyword); } else { Writer(); } } break; } while (input

Create a dynamic 'if' statement in Excel without VBA

北慕城南 提交于 2019-12-25 03:34:08
问题 * Updated * I have a rather large excel data set that I'm trying to summarise using up to 3 dimensions: region, sector, industry. Any combination of these dimensions can be set or left blank and I need to create a formula that accommodates this WITHOUT using VBA. Within the data I've set up named ranges to refer to these dimensions. I'm using an array formula but I'd like to dynamically create a string which is then used as the boolean argument in the array formula. For instance if: A1 =

If x enter data, else retrieve data. PHP & SQL

懵懂的女人 提交于 2019-12-25 03:33:04
问题 Here is my code, I have been attempting to find a way to do this. The point of the code is to do this: Check database, see if field is filled, if not post form. Once form is filled, submit data to database, then reload page to go to step 2. Else if field is full show data in database, and bypass the first part. <?php require_once('connectvars.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org

radio button show values in combo box

最后都变了- 提交于 2019-12-25 03:31:07
问题 I confused with this if-else because I'm new in Java & MySQL and I tried to make it by myself. public Menu() { initComponents(); try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/restaurant", "root", ""); System.out.println("ODBC Connection Successful"); showCategory(); } catch (ClassNotFoundException | SQLException e) { System.out.println("ODBC Connection Failed" + e); } } if - else private void showCategory() { try { Statement stmt;

Trouble With If statement PHP

北城以北 提交于 2019-12-25 03:29:42
问题 I have been scripting PHP for for about 9 months now and im starting to run into a problem with my if conditions. This has never happened before. if ($reason != "9ee1e1f4fbf1"){ XXXXXXXXX } I even tried putting the 9ee1ef4fbf1 in parenthesis and that didnt work. i keep getting this: Parse error: syntax error, unexpected T_IF in /home/content/49/549/html/index.php on line 21 回答1: The problem is in the line above the if. Maybe forgot a semicolon? 回答2: Please post the lines before the if