conditional

Inline Conditional Statement in Stored Procedure

Here is the pseudo-code for my inline query in my code: select columnOne from myTable where columnOne = '#variableOne#' if len(variableTwo) gt 0 and columnTwo = '#variableTwo#' end I would like to move this into a stored procedure but am having trouble building the query correctly. I assume it would be something like select...

Conditionally compiling entire namespaces - C#

Hi there, I was wondering if there is a way to conditionally compile entire namespaces in C#. Or am I left with having to explicitly decorate each source file within the namespace with the preprocessor directives to exclude it? In sub-versions of my application the code in various namespace is simply not required and I would like it exc...

How can I join conditionally in LINQ queries?

If I have two tables; Drivers keyed by DriverId and Trips with foreign keys DriverId and CoDriverId, and I want to find all trips where a driver was either the driver or co-driver I could code this in Transact-SQL as select d.DriverId, t.TripId from Trips t inner join Drivers d on t.DriverId = d.DriverId or t.CoDriverId = d.DriverId ...

Where do I put common code for if and elif?

For the example below: if a == 100: # Five lines of code elif a == 200: # Five lines of code Five lines of code is common and repeating how can I avoid it? I know about putting it a function or if a == 100 or a == 200: # Five lines of code if a == 100: # Do something elif a == 200: # Do somet...

SQL Where clause conditional assignment based on another parameter

I need to generate a report where the user can choose All Issues, Open Issues, or Closed issues in a radio button. In my view I have a isClosed bit column. If I didn't have the All Issues radio box I'd just do: SELECT * FROM MyView WHERE isClosed = @ViewClosedRecords However I need to remove the isClosed = @ViewClosedRecords condition...

How do I make these fields autopopulate from the database?

I have an array, which holds values like this: $items_pool = Array ( [0] => Array ( [id] => 1 [quantity] => 1 ) [1] => Array ( [id] => 2 [quantity] => 1 ) [2] => Array ( [id] => 72 [quantity] => 6 ) [3] => Array ( [id] => 4 [quantity] => 1 ) [4] => Array ( [id] => 5 [quantity] => 1 ) [5] => Array ( [id] => 7 [quantity] => 1 ) [6] ...

IE Conditional Comments: lt IE 7 = lte IE 6?

Hi! Are there any differences using <!--[if lt IE 7]>...<![endif]--> or <!--[if lte IE 6]>...<![endif]--> ? ...

Building an *efficient* if/then interface for non-technical users to build flow-control in PHP

I am currently building an internal tool to be used by our management to control the flow of traffic. I have built an if/then interface allowing the user to set conditions for certain outcomes, however it is inefficient to use the switch statement to control the flow. How can I improve the efficiency of my code? Example of code: ...

Conditional statements bug in Google Chrome

When I use a conditional statement targeting IE6 and below with some PHP code Google Chrome disregards the statement and inserts the code. Example: <!--[if lte IE 6]> <?php require_once("ie6.php"); ?> <![endif]--> It will insert the content of ie6.php in the body anyway. The code in ie6.php is something like this: <?php print '<p>T...

Chained inequality notation in programming languages

Is there a programming language that supports chained notation a < b < c to be used instead of a < b and b < c in conditional statements? Example: if ( 2 < x < 5 ) if ( 2 < x && x < 5 ) First statementlooks better to me, it's easier to understand and the compiler could use transitivity property to warn about mistakes (e.g. 5 < x < 2...

PHP conditional loop help

Hi there in my database I have 3 columns, is_contract, is_permenant and is_temporary. Within these columns there is either a Y or N value. I am using these columns to echo onto the page what kind of work someone is looking for, my problem is that the user can be looking for more than one type of work, I am currently running 3 if state...

PHP get a boolean when it is set later in the page

In the header of my page I have a conditional statement to check if $foo boolean is set, the trouble is that the $foo boolean doesn't get set until the footer is loaded. Any way to retroactively check the status of this boolean? ...

Check if a selector have a certain set of classes

Hello I'm trying to be able to check if a selector have a certain sets of classes. .hasClass() can only check if the selector has one class. And the .is() selector can look for multiple classes but will return true if the selector have at least one of the classes. But I wan't to achieve a way to check if a selector have both of the c...

Is it possible to conditionally require_once, set globals, or set constants?

I have a particular php class that I want to be able to upload identical copies to two different servers. Depending on the server though, the requires will be located in different places. (the constants and globals are slightly different as well) Can I conditionally set require_once, Globals, or constants at the beginning of the file? ...

php URI troube with if statement,

I am running an if statement, that looks like this, if($this->uri->segment(1) !== 'search' || $this->uri->segment(1) !== 'employment') { //dome something } My problem is that first condition works, if the uri segment 1 equals search then the method do not run however if I on the page employment, and the first segment of the uri i...

How to not run function if its a mobile device?

I have a modal pop up function on my website, but i don't want this to run if the browser is smaller than 480px. I have found that if I put an if statement such as: if (window.innerWidth && window.innerWidth > 480) { run function() } Then it should run only if the browsers innerWidth is > 480. However its not working and I think its...

Incrmenting a Cookies with PHP (Beginner Question)

Hello, I have used sessions before but never cookies. I would like to use cookies for two reasons: 1) it's something new to learn 2) I would like to have the cookie expire in an hour or so (i know in the code example it expires in 40 sec) I am trying to write a basic if statement that if($counter=="1") { //do this second } ...

what is means of this code

if (exist.IndexOf("true") == -1) { //first condition } else { // second condition } what is means of it if i use (exist.IndexOf("true") != -1) ...

Jquery cookie plugin - conditional content determined by cookie being set

Hello I have a sign up form that is displayed to all new site visitors. If a user fills out the form, the next time they visit the site, I would like to display a "welcome back" message where the form would usually sit. I am trying to do this via the jquery cookie plugin (http://plugins.jquery.com/project/Cookie). My form would look ...

Java: how to have try-catch as conditional in for-loop?

I know how to solve the problem by comparing size to an upper bound but I want a conditional that look for an exception. If an exception occur in conditinal, I want to exit. import java.io.*; import java.util.*; public class conditionalTest{ public static void main(String[] args){ Stack<Integer> numbs=new Stack...