conditional

Conditionally insert a row

I'd like to insert a row into table A, but only if another row in table B exists. For example something like this... IF EXISTS (SELECT * FROM B WHERE id=1) INSERT INTO A (id, value1, value2) VALUES (1, 'foo', 'bar') However that doesn't work. What will? ...

Java String initialization

Which do you prefer and why" String myString = null; if(someCondition) myString = "something"; else myString = "something else"; OR String myString = ""; if(someCondition) myString = "something"; else myString = "something else"; I know that using the ternary (? :) operator is possible but I'd like to know about the abo...

Is this valid PHP syntax?

if ($var == ($var1 || $var2)) { ... } I am considering using this, but am ont sure if it is valid, and there doesn't seem to be somewhere to check. It seems logically consistent to me but am not sure, and I don't have something to test it on close by. If it is valid, what other mainstream languages support this sort of construct. ...

Help with JQuery conditional statement

I am trying to run some JQuery script on a particular page but only if a certain page loads. The Scenario: We have one page that loads (i.e., webpage.aspx) and it loads different content based on the referring click. (i.e., webpage.aspx?contentId=1, webpage.aspx?contentId=2, webpage.aspx?contentId=3, etc). Here is my problem. I need ...

using conditions in magento layout xml

Hi all, Wondering if anyone has used the or statements in magento's layout XML for a custom module? I realise that I could check the values in the module controller or block itself, but it seems like a logical place for the logic to live. Mage_Core uses them in catalog.xml to test for javascript. <!--<params/><if/><condition>can_loa...

I need to know how i can write IF statements and CASE break statements that use and execute queries, etc in MySQL ?

I need to execute a query that is highly dependent on several conditions what need to be checked by analyzing that data in other tables, the base goal is to return the rows from the tables if all of the conditions in the other tables are true, I am fed up with INNER joins LEFT joins and WHERE statement, i need to look up one table, if th...

Wordpress two conditions (and if)

I'm writing a sidebar for my site and I'm trying to check if: The page is a post, via: is_post() The author can edit the post via: current_user_can('edit_post') I'm trying to combine both of these conditions, but I'm horrid at PHP and I just can't figure out the syntax to do so. I figured it'd be something like below. Could you pleas...

Rewriting a conditional statement in Java

Say if I have the code below, it's bascially determining some condition is matched and then assign the boolean value, then run some codes. Then throw an exception if the booleanValue is false. What if I want it to throw an exception immediately if the booleanValue is false without running the rest of the codes? If I just put the second c...

Wordpress Multi Loop Conditional Conflict

Alright I have two loops going, on in the body and on in the sidebar. I also have a conditional statement in the footer that generates another loop. The problem I'm running into is the use of the conditional statement in the footer. Because the loop in the sidebar was called last, Wordpress is using its variables in the conditional state...

Using if is_page() Wordpress conditional statement

Hi all, I'm trying to have different pictures on every one of my pages built on wordpress. So I have the following in my index.php file, archive.php file, page.php file, etc: <img src="<?php bloginfo('template_url'); ?>/images/<?php echo $toppic; ?>" alt="page1" id="mainPageImg" /> Now, in my page.php file, I have the following: <?...

PHP: Conditional statement with possible empty variables

I'm creating a custom search form and when I try and sort the results I get all the objects displayed instead of the matched criteria. The reason I discovered was that some of the inputs from the form don't have a default value and when this is not declared in the conditional statement later on (for sorting) it just shows all the objects...

What's the difference between if and elseif?

This should be a simple question. I have a simple if/else statement: <?php // TOP PICTURE DEFINITIONS if ( is_page('english') ) { $toppic = 'page1.png'; } if ( is_page('aboutus') ) { $toppic = 'page1.png'; } if ( is_page('newspaper') ) { $toppic = 'page1.png'; } else { ...

Can I make fields visible only if image attach has an image

Is it possible to use CCK to add a conditional to the image attach module form where unless I have selected an image to use for a content node, certain fields are not visible? Currently I do not have any operations available for my image attach field in my content type definition where configure and remove are available for all other fi...

Error: Expected primary-expression before '=='

Hello.. I'm trying to work through a book on C and I am stuck on the following error: while((c = getchar()) != EOF){ if(c >= '0' && c <= '9'){ ++ndigit[c-'0']; } else if (c == ' ' || c == '\n' || == c =='\t'){ ++nwhite; } else{ ...

conditional probability

Hi, Could you inform me please, how can I calculate conditioned probability of several events? for example: P (A | B, C, D) - ? I know, that: P (A | B) = P (A intersection B) / P (B) But, unfortunately, I can't find any formula if an event A depends on several variables. Thanks in advance. ...

SQL Subqueries COUNT CASE

I'd like a SELECT query to return specific value if the count of a nested subquery is 0 ... SELECT ( SELECT (CASE COUNT(*) = 0 THEN 'TRUE' ELSE 'FALSE' END) FROM List WHERE Status = 1 AND Deleted = 1 ) AS Status This does not work what is wrong with this syntax? ...

WiX: InstallService conditionally, but install file unconditionally

In Windows Install XML toolset, to install a service, we group <ServiceInstall> with a <File> in a <Component>. To conditionally install the service, we put <Condition> under the <Component>. However if the condition is false, the file will not be installed too. If I put the <File> in an unconditional <Component>, then the service has no...

Zend Framework: Conditional validation

I need to set up some validation for a form field based on a value of another field. For instance if profession is Doctor, then require specialty not to be blank ('') or none ('none'). $professionOptions = array( '' => 'Choose Profession', 'Dr.' => 'Dr.', 'zzz' => 'zzz', 'None' => 'None'); $th...

validating json string using javascript...

I have this json string {"Table" : [{"subject" : "No Records are there to Display"}]}. If i receive this data i want to alert NO Records Found. Any suggestion. Note: My key field may vary accordingly (ie) here it is Subject and some more like Details,Description. ...

JavaScript If statement condition with no operator? What does it do?

I am used to if statements having a condition where ( x < y ) or ( x == y ). But in cases where there is no operator, what does the if statement check exactly? i.e. in the example below if (window.XMLHttpRequest)... what's the condition? Thanks. if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new ...