conditional

Stripping HTML Comments With PHP But Leaving Conditionals

I'm currently using PHP and a regular expression to strip out all HTML comments from a page. The script works well... a little too well. It strips out all comments including my conditional comments in the . Here's what I've got: <?php function callback($buffer) { return preg_replace('/<!--(.|\s)*?-->/', '', $buffer); } ...

SQL conditional SELECT

Hi I would like to create a stored procedure with parameters that indicate which fields should be selected. E.g. I would like to pass two parameters "selectField1" and "selectField2" each as bools. Then I want something like SELECT if (selectField1 = true) Field1 ELSE do not select Field1 if (selectField2 = true) Field2 ELSE do no...

conditional rules htaccess

hi, Currently, my .htaccess file looks like htis: IndexIgnore */* RewriteEngine on RewriteRule ^add /add.php RewriteRule ^add/$ add.php RewriteRule ^sitemap.xml /xmlsitemap.php RewriteRule ^([^/\.]+)$ /index.php?slug=$1 RewriteRule ^([^/\.]+)/$ /index.php?slug=$1 It works fine for links as: site.com/category/ However, i would like t...

Which block of code is 'better'?

In order to promote good programming habits and increase the efficiency of my code (Read: "My brother and I are arguing over some code"), I propose this question to experienced programmers: Which block of code is "better"? For those who can't be bothered to read the code, is it worth putting a conditional within a for-loop to decrease t...

JSTL: check if property doesn't exist

I'm getting blocked on a jsp page and our 1 java engineer isn't able to help now. There is a template called "module-review.jsp" that is loaded in 2 instances, via a normal page load an via an api that returns it as part of a json object. There is a variable called "review.updatedDate". On a normal page view, this variable is loaded a...

What is the PHP ? : operator called and what does it do?

Can someone please explain what the "?" and ":" operators are in PHP? e.g.: (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) ...

conditional include in linq to entities?

I felt like the following should be possible I'm just not sure what approach to take. What I'd like to do is use the include method to shape my results, ie define how far along the object graph to traverse. but... I'd like that traversal to be conditional. something like... dealerships .include( d => d.parts.where(p => p.price < 1...

WPF ObjectDataProvider IsAsynchronous Complete and conditional databinding

Kind of a two part question... first let me explain what I am trying to accomplish. I have a basic window that is laid out as follows Server (combobox) that pulls a list of sql servers: <ObjectDataProvider x:Key="SQLServerList" ObjectInstance="{x:Static data:Sql.SqlDataSourceEnumerator.Instance}" MethodName="GetDataSources" IsAsynchro...

Include ServiceDependancy if checkbox selected WIX

Is it possible to include a ServiceDependency based on whether a checkbox was selected in a WIX application? ...

CONDITION CSS differentiate between IE6 to IE7

i want to declare a style different to ie6 and ie7 , but my condition in css recognized by IE7 as IE6. I use XP and explorer 7. This the code i use : <!--[if !IE]> #mainDiv{text-align:-moz-center;} #skyBanner {top:0px;left:0px; position:fixed;visibility:hidden;} <![endif]--> <!--[if lt IE 7]> body > #skyBanner { position: fi...

Show WPF Tooltip if needed

I have a TextBlock inside a limited-size control. If the text is too long to fit into the control, I'd like to show a tooltip with full text. This is a classic behavior you surely know from many apps. I tried using a Converter to convert TextBlock width into Tooltip's Visibility. <GridViewColumn.CellTemplate> <DataTemplate> ...

MySQL conditonal query inside where clause

I'm not sure if I'm missing something really obvious, but I keep getting a syntax error on this query. Even if I AM missing something obvious, I'd like to know if there is a smarter way of getting what I'm after. Basically, the query asks for any rows tied to a user with a start_date between Monday and Friday. That works great. But then...

Single Equals in MYSQL

Hi, I was wondering why MYSQL uses a single equals sign in conditional statements instead of the more typical two equals signs. Is there a technical/historical reason for this? Thanks. ...

can you begin a mysql statement with "IF"?

I am trying to implement "IF record EXISTS THEN UPDATE ELSE INSERT" in mysql. Specifically, I have to figure out how to do that with Doctrine ORM. One solution using native MySql is to use "ON DUPLICATE KEY UPDATE". This is unfortunately not supported in Doctrine. Another semi solution is to use "REPLACE INTO" syntax. Doctrine sup...

Conditional operator with only true statement

I want to set a variable to a value, but only if a condition is true. Instead of doing the following: if($myarray["foo"]==$bar){ $variablename=$myarray["foo"]; } This can end up being quite long if the variable names are long, or perhaps it involves arrays, when it's quite simple what I want to do set a value if a condition ...

How do I Write a SQL Query With a Condition Involving a Second Table?

Table1 ... LogEntryID *PrimaryKey* Value ThresholdID - - - Link to the appropriate threshold being applied to this log entry. ... Table2 ... ThresholdID *PrimaryKey* Threshold ... All fields are integers. The "..." thingies are there to show that these tables hold a lot more imformation than just this. They are set up this way for ...

PHP VLookup (conditional match) Alternative?

How do I return the results for the provision_id column so that they are conditional on contracts.id for each row? Right now, I get the same result on every row. The desired effect is sort of like VLookup in Excel. Not sure how to use if else/sql values to achieve it in PHP though. Relevant code: <?php global $wpdb; $contents = $wpdb-...

MySQL coalesce for some null, not all null

I have a MySQL query that checks an employee schedule DB and (thanks to a previous stackoverflow question) returns any days that the user is not working as "No Work", so that if the user isn't working on Thursday, the query fills in that date even though the date does not appear in the original result set (and so I don't have to fill in ...

In C, which is faster: if with returns, or else if with returns?

Is it better to have if / else if, if every block in the if statement returns, or is it better to have a chain of ifs? To be specific, which if fastest: A: if (condition1) { code1; return a; } if (condition2) { code2; return b; } //etc... B: if (condition1) { code1; return a; } else if (condition2) { code2; return b;...

Strange php if statement problem

if($country == 224 || $country == 223 || $country == 39 && $zip == '' ){ $_SESSION['sess_msg'] = "Please enter a Valid zipcode"; header("location: $SITE_PATH?p=account.profile.name"); exit; } variable value -------- ----- $country 224 $zip 11111 I know that $zip isn't empty, but the code executes as if it i...