if-statement

If statement parsing incorrectly

三世轮回 提交于 2019-12-25 08:07:24
问题 I am trying to get this if statement to follow as: if the first string position is .png, then get $png1 from a haystack, but if the first string position is .jpg, then get $jpg1 from the haystack, but if it is .gif, get $gif1 from haystack, else if none of them are found then the string position is .bmp so get $bmp1 Here is what i tried, but it doesn't parse correctly: <?php // if first occurence is .png get $png1 needle from haystack if (preg_match('#cid:([^"@]*).png@([^"]*)#', $html_part))

MySQL Trigger: Prevent Insert by IF statement

≡放荡痞女 提交于 2019-12-25 07:59:12
问题 I try to write my first trigger for a MySQL Database. It should prevent an insert (and later also updates) on " course_student " in context of the current time and the given timestamps in " capacity ", but i'm still getting a syntax error. DELIMITER $$ CREATE TRIGGER checkSubscribeTimeCourse BEFORE INSERT ON course_student REFERENCING NEW AS new FOR EACH ROW BEGIN IF (SELECT COUNT(*) FROM capacity c, course_capacity cc WHERE c.cid = cc.cid AND cc.cid = new.cid AND (c.end >= CURRENT_TIMESTAMP

Return a vector of Grades from if-else statements

别说谁变了你拦得住时间么 提交于 2019-12-25 07:19:01
问题 I have an if-else if construct which gives me grades A, B, C, D, F depending on marks from 0-100. if (mark > 100) | (mark < 0) disp('Invalid mark'); return; % Exit from the program. end % Of first if statement if mark >= 80 % Mark is in range 80 - 100. grade = 'A'; elseif mark >= 70 % Mark is in range 70 - 79. grade = 'B'; elseif mark >= 60 % Mark is in range 60 - 69. grade = 'C'; elseif mark >= 50 % Mark is in range 50 - 59. grade = 'D' else % Mark is in range 0 - 44. grade = 'F'; end disp

PHP if-statement screen width

偶尔善良 提交于 2019-12-25 07:18:26
问题 I want to check if the screen width is higher than 1024 pixels, to set sidebar + 50px I tried this piece of code (but the sidebar doesnt load on 1024+): <?php $arjunaOptions = arjuna_get_options(); ?> <?php //calculate sidebar and content area ratio if ($arjunaOptions['sidebarDisplay'] != 'none') { $available = 920; $available2 = 970; $contentArea = $arjunaOptions['contentAreaWidth']; $sidebar = $available - $contentArea; $sidebarlarge = $available2 - $contentArea ; $sidebarLeftRight = floor(

Applying multiple conditions to formula

 ̄綄美尐妖づ 提交于 2019-12-25 06:59:49
问题 I have a situation where I need to apply several "value boundaries" to several different "starting positions" and then subsequently output the "ongoing position". The "value boundaries" are: <500, >=500<750, >750<=850 and >850 The "starting positions" are "Basic", "Standard", "Standard+", and "Platinum", The value boundaries are then applied and the "ongoing position" outputted, e.g. a person starting at "Basic" achieves 600 and then moves to "standard", or someone at "Platinum" gets 700 so

What is the best way to supply many arguments to an if statement?

梦想与她 提交于 2019-12-25 06:59:27
问题 I have created a form with several user inputs but have the tedious task of checking whether each individual input is not empty before submission. Is there a quicker way, (such as using arrays perhaps) of listing all arguments to the if statement? At the moment my code looks like this but if possible I would like it to be more efficient in future, like if I were to add more inputs. <form action="sign-up.php" method="post" autocomplete="off" > Name:<input type="text" name="name" /> Username:<

Condensing If Statement Batch File

冷暖自知 提交于 2019-12-25 06:51:50
问题 I have this batch script that has numerous "if statements". Here are a couple lines of what I have: if %c%==PC exit if %c%==pc exit if %c%==CMD exit if %c%==cmd exit if %c%==MENU exit if %c%==menu exit if %c%==KILL exit if %c%==kill exit There are many more possibilities and really could use some simplifying if it is possible. So is there a way I can simplify this? Perhaps something like, if the variable c is equal to any of these exit. Or even make the if statements case insenstitive Is this

Type mismatch exception

折月煮酒 提交于 2019-12-25 06:37:17
问题 I am developing game, Initially I was using boolean while decalring arrays, latter it revealed that instead of using boolean I should use int in order to store state of game, When I replaced boolean with int my if statement shows type mismatch exception and The operator && is undefined for the argument type(s) boolean, int . Here is my if statement code. int [][] dots protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawPaint(pBack); for (int y = 0; y < numRows; y++) {

render a scrollview after a condition in react native

夙愿已清 提交于 2019-12-25 06:34:57
问题 i need to display a scrollview in react native application, after a condition using if. In fact, i have a list of items in firebase that contain text and title but sometimes they may contain images also. I need to display that list of text and titles in the exact same order and also the images if there is any. here the code i used _renderScrollViewContent() { const data = this.state.items if (data.image) { return ( <View> {data.map((item, i) => <View key={i}> <Image source={require('path')}/>

simple beginner search program using arrays in javascript, issue with displaying

放肆的年华 提交于 2019-12-25 06:15:42
问题 I am creating a simple search program that searches for my name block of text. The issue I am having is at the end, when I place the letters in the array, they seem to come out a single character on each line, rather than uniformly in one single block of text. Can anyone point out the discrepancy? var text = "hah hah Aaron hah hah Aaron\ hah hah hah hah hoh Aaron hah hah hah hah\ Aaron Aaron Aaron hah"; var myName = "Aaron"; var hits = []; for (var i =0; i< text.length; i++) { if (text[i] ===