Search Results

Search found 28469 results on 1139 pages for 'select statement'.

Page 5/1139 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • PHP IF statement not taking variable into account!

    - by Jess
    I have a tabled view in a while loop, where a user can view information on books. For example, book ISBN, book name, read status... Basically, when the user sets their 'readstatus' to 'complete' I want that specific table row to become grey! The logic is very straight forward, however I can't get my IF statement to recognise this: $readstatus = $_GET['readstatus']; if ($readstatus == 'complete') { echo '<tr class="completed">'; } else if ($readstatus != 'complete') { echo '<tr class="reading">'; } I'm obviously doing something wrong here, but all I need is the CSS class of the table row to change if the value of 'readstatus' = 'complete', if not, then output the default CSS table row color ('reading') Should I be putting $result as the variable or something? I have this coming just before my nested IF statement: $result = mysql_query($sql, $connection) or die ("Couldn't perform query $sql <br />".mysql_error()); while($row = mysql_fetch_array($result)) { ?>

    Read the article

  • jQuery can't get if statement to work

    - by jstacks
    I'm looking help with an If Statement. I'm trying to finalize this horizontal scrolling I have and the last bit is to not just disable scrolling when the end is reached, but to also disable (well, change color) the scroll buttons at that point as well. And change back when they are scrollable again. http://jsfiddle.net/stfzy/83/ EDIT* I've updated the JQuery and have everything working except just one if statement: $('div#arrowL').click(function(){ if(index < 0 ){ //can't scroll $('div#arrowL').addClass('active'); } }); I need to add this class back when you can't scroll left anymore. And I think the issue is with the "index < 0" portion but I don't see what I need to change it to to get it to work. Any help is appreciated.

    Read the article

  • jQuery Mobile and Select menu with URLs

    - by user1907347
    Been battling with this for a while now. I'm trying to get a select menu to work as a navigation menu but I cannot get the URLs to work and have it actually change pages. In the head: <script> $(function() { $("#select-choice-1").click(function() { $.mobile.changePage($("#select-choice-1")); }); }); </script> With this Menu: <div id="MobileWrapper" data-role="fieldcontain"> <select name="select-choice-1" id="select-choice-1" data-theme="a" data-form="ui-btn-up-a" data-mini="true"> <option data-placeholder="true">Navigation</option><!-- data=placeholder makes this not show up in the pop up--> <option value="/index.php" data-ajax="false">Home</option> <option value="/services/index.php" data-ajax="false">Services</option> <option value="/trainers/index.php" data-ajax="false">Trainers</option> <option value="/locations/index.php" data-ajax="false">Locations</option> <option value="/calendar/index.php" data-ajax="false">Calendar</option> <option value="/contactus/index.php" data-ajax="false">Contact Us</option> </select> </div><!--END MobileWrapper DIV-->

    Read the article

  • ms sql use like statement result in if statement

    - by Asha
    declare @d varchar set @d = 'No filter' if (@d like 'No filter') BEGIN select 'matched' end else begin select 'not matched' end the result of above is always not matched can anybody tell me why and how can I use the like or '=' result in my stored procedure. thanks

    Read the article

  • Update table with if statement PS/SQL

    - by Matt
    I am trying to do something like this but am having trouble putting it into oracle coding. BEGIN IF ((SELECT complete_date FROM task_table WHERE task_id = 1) IS NULL) THEN UPDATE task_table SET complete_date = //somedate WHERE task_id = 1; ELSE UPDATE task_table SET complete_date = NULL; END IF; END; But this does not work i also tried IF EXISTS(SELECT complete_date FROM task_table WHERE task_id = 1) with no luck

    Read the article

  • MySQL: select words as rows even som are "new line" separated in one field

    - by Tillebeck
    Hi I have a table with a field where words are written separated with new lines. So a select on this single field from to rows will output 3 lines for first row and 2 lines for second row: Row1 designationer nye kolonier mindre byer Row2 udsteder bopladser I would like to do a select that select all these lines as if they had been rows in the table like: SELECT do_the_split(field) FROM table so the result would be more like: Row1 designationer Row2 nye kolonier Row3 mindre byer Row4 udsteder Row5 bopladser is there any way to do this in MySQL? BR. Anders

    Read the article

  • Javascript: Select option based on its contents

    - by Zac Altman
    Basically this, but in pure javascript: http://stackoverflow.com/questions/2346257/how-to-get-value-of-select-tag-based-on-content-of-select-tag-using-nokogiri So I have a select list with a lot of countries/states, and I want to be able to select one based on what is between the tags. Argentina (I know i could use the value, but each one is a random mesh of numbers, so i would have to collect each individual one - not economical...)

    Read the article

  • NUmber of rows in Oracle SQL Select?

    - by twelshesgi
    I need to nkw how many records were returned in a select in oracle. Currently, I do two queries: SELECT COUNT(ITEM_ID) FROM MY_ITEMS; SELECT * FROM MY_ITEMS; I need to know the COUNT but I hate doing two queries. Is there a way to do: SELECT * FROM MY_ITEMS and then find out how many records are in there?

    Read the article

  • Is select function internaly call tcp connect ?

    - by Syedsma
    Code Sinnpet: int CreateaTCPSocket() { int iSockID = ACE_OS::socket(......); ACE_OS::set_flags(iSockID,O_NONBLOCK); ACE_OS::bind(); if (ACE_OS::connect(iSockID ,....) < 0) { if (ACE_OS::select(.....,timeout) <= 0) { return INVALID_HANDLE; } } return iSockID; } My question is when connect is failed for non-block error and select is called and say select return success then again we need to call connect or select function internal do connect?

    Read the article

  • SQL Queries SELECT IN and SELECT NOT IN

    - by Sequenzia
    Does anyone know why the results of the following 2 queries do not add up to the results of the 3rd one? SELECT COUNT(leadID) FROM leads WHERE makeID NOT IN (SELECT uploadDataMapID FROM DG_App.dbo.uploadData WHERE uploadID = 3 AND uploadRowID = 1) AND modelID NOT IN (SELECT uploadDataMapID FROM DG_App.dbo.uploadData WHERE uploadID = 3 AND uploadRowID = 2) SELECT COUNT(leadID) FROM Leads WHERE makeID IN (SELECT uploadDataMapID FROM DG_App.dbo.uploadData WHERE uploadID = 3 AND uploadRowID = 1) OR modelID IN (SELECT uploadDataMapID FROM DG_App.dbo.uploadData WHERE uploadID = 3 AND uploadRowID = 2) SELECT COUNT(leadID) FROM Leads The first query is the count I need. The second one is to tell the user how many records were suppressed based on the contents of the DG_App.dbo.uploadData table. The third query is just a straight count of all the records. When I run these the results of query 1 + the results of query 2 comes up about 46K records less than the count of the entire table. I have played with grouping the WHERE statements with () but that did not change the counts at all. This is MSSQL Server 2012. Any input on this would be great. Thanks

    Read the article

  • performance issue: difference between select s.* vs select *

    - by kamil
    Recently I had some problem in performance of my query. The thing is described here: poor Hibernate select performance comparing to running directly - how debug? After long time of struggling, I've finally discovered that the query with select prefix like: select sth.* from Something as sth... Is 300x times slower then query started this way: select * from Something as sth.. Could somebody help me, and asnwer why is that so? Some external documents on this would be really useful. The table used for testing was: SALES_UNIT table contains some basic info abot sales unit node such as name and etc. The only association is to table SALES_UNIT_TYPE, as ManyToOne. The primary key is ID and field VALID_FROM_DTTM which is date. SALES_UNIT_RELATION contains relation PARENT-CHILD between sales unit nodes. Consists of SALES_UNIT_PARENT_ID, SALES_UNIT_CHILD_ID and VALID_TO_DTTM/VALID_FROM_DTTM. No association with any tables. The PK here is ..PARENT_ID, ..CHILD_ID and VALID_FROM_DTTM The actual query I've done was: select s.* from sales_unit s left join sales_unit_relation r on (s.sales_unit_id = r.sales_unit_child_id) where r.sales_unit_child_id is null select * from sales_unit s left join sales_unit_relation r on (s.sales_unit_id = r.sales_unit_child_id) where r.sales_unit_child_id is null Same query, both uses left join and only difference is with select.

    Read the article

  • Select Box not filling properly in rails

    - by CaptnCraig
    I am creating a select box for a form using this in _form.html.erb <%= f.select(:category_id,options_for_select(@cats)) %> @cats is an array created in my controller like this: @cats = [] categories.each do |c| @cats.push([c.full_name,c.id]) end The select box is properly filled, and the selected foreign key is even properly saved to the database. The problem is, when I come back in my edit action, the select box is moved back to the first item in the list, not the one corresponding to category_id. Reading the documentation it seems like this should just magically work. How do I get it to select the proper value?

    Read the article

  • Switch statement usage - C

    - by Jamie Keeling
    Hello, I have a thread function on Process B that contains a switch to perform certain operations based on the results of an event sent from Process A, these are stored as two elements in an array. I set the first element to the event which signals when Process A has data to send and I have the second element set to the event which indicates when Process A has closed. I have began to implement the functionality for the switch statement but I'm not getting the results as I expect. Consider the following: // //Thread function DWORD WINAPI ThreadFunc(LPVOID passedHandle) { for(i = 0; i < 2; i++) { ghEvents[i] = OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("Global\\ProducerEvents")); if(ghEvents[i] == NULL) { getlasterror = GetLastError(); } } dwProducerEventResult = WaitForMultipleObjects( 2, ghEvents, FALSE, INFINITE); switch (dwProducerEventResult) { case WAIT_OBJECT_0 + 0: { //Producer sent data //unpackedHandle = *((HWND*)passedHandle); MessageBox(NULL,L"Test",L"Test",MB_OK); break; } case WAIT_OBJECT_0 + 1: { //Producer closed ExitProcess(1); break; } default: return; } } As you can see if the event in the first array is signalled Process B should display a simple message box, if the second array is signalled the application should close. When I actually close Process A, Process B displays the message box instead. If I leave the first case blank (Do nothing) both applications close as they should. Furthermore Process B sends data an error is thrown (When I comment out the unpacking): Have I implemented my switch statement incorrectly? I though I handled the unpacking of the HWND correctly too, any suggestions? Thanks for your time.

    Read the article

  • Rails - Active Record :conditions overrides :select

    - by Nick
    I have a fairly large model and I want to retrieve only a select set of fields for each record in order to keep the JSON string I am building small. Using :select with find works great but my key goal is to use conditional logic with an associated model. Is the only way to do this really with a lamda in a named scope? I'm dreading that perhaps unnecessarily but I'd like to understand if there is a way to make the :select work with a condition. This works: @sites = Site.find :all, :select => 'id,foo,bar' When I try this: @sites = Site.find :all, :select => 'id,foo,bar', :include => [:relatedmodel], :conditions => ["relatedmodel.type in (?)", params[:filters]] The condition works but each record includes all of the Site attributes which makes my JSON string way way too large. Thanks for any pointers!

    Read the article

  • Variable not implementing correctly from if statement

    - by swiftsly
    I have an if statement that is supposed to set the variable $pc162v to a link specified in the MySQL table if content exists in the $vid column of the row. The problem is, the PHP is detecting that there's a link in the MySQL, but isn't setting the $pc162v variable correctly. Here's the variable declarations: $pc162v = ""; $vid162 = '<embed width="420" height="236" src="'.$pc162v.'" type="application/x-shockwave-flash"></embed>'; Here's the section of the if statement: if (empty($row[7])) { $vid162 = ''; } else { $pc162v = $row[7]; } In my web browsers, the part of the code where the variable $vid162 is used, shows up as the following: <embed width="420" height="236" src="" type="application/x-shockwave-flash"> I have also tried setting $vid162 to: <embed width="420" height="236" src="<?php echo $pc162v; ?>" type="application/x-shockwave-flash"></embed> and that just makes the code in my web browser: <embed width="420" height="236" src="<?php echo $pc162v; ?>" type="application/x-shockwave-flash"> Hope someone has a solution! Thanks in advance.

    Read the article

  • Select Menu, go to url on select with JQuery?

    - by Keith Donegan
    Hey Guys, I have the following html: HTML markup <ul id="test"> <li><a href="http://www.yahoo.com">yahoo</a></li> <li><a href="http://www.google.com">Google</a></li> </ul> And some JS code: JQuery/JavaScript Code $('ul#test').each(function() { var select=$(document.createElement('select')).insertBefore($(this).hide()); $('>li a', this).each(function() { option=$(document.createElement('option')).appendTo(select).val(this.href).html($(this).html()); }); }); This code produces a select dropdown menu, exactly what I want, but my question is how do I go to the url on select? So if I click yahoo, it brings me to yahoo.com? Thanks for your help!

    Read the article

  • select row from table and substitute a field with one from another column if it exists

    - by EarthMind
    I'm trying construct a PostgreSQL query that does the following but so far my efforts have been in vain. Problem: There are two tables: A and B. I'd like to select all columns from table A (having columns: id, name, description) and substitute the "A.name" column with the value of the column "B.title" from table B (having columns: id, table_A_id title, langcode) where B.table_A_id is 5 and B.langcode is "nl" (if there are any rows). My attempts: SELECT A.name, case when exists(select title from B where table_A_id = 5 and langcode= 'nl') then B.title else A.name END FROM A, B WHERE A.id = 5 and B.table_A_id = 5 and B.langcode = 'nl' -- second try: SELECT COALESCE(B.title, A.name) as name from A, B where A.id = 5 and B.table_A_id = 5 and exists(select title from B where table_A_id = 5 and langcode= 'nl') I've tried using a CASE and COALESCE() but failed due to my inexperience with both concepts. Thanks in advance.

    Read the article

  • Which index is used in select and why?

    - by Lukasz Lysik
    I have the table with zip codes with following columns: id - PRIMARY KEY code - NONCLUSTERED INDEX city When I execute query SELECT TOP 10 * FROM ZIPCodes I get the results sorted by id column. But when I change the query to: SELECT TOP 10 id FROM ZIPCodes I get the results sorted by code column. Again, when I change the query to: SELECT TOP 10 code FROM ZIPCodes I get the results sorted by code column again. And finally when I change to: SELECT TOP 10 id,code FROM ZIPCodes I get the results sorted by id column. My question is in the title of the question. I know which indexes are used in the queries, but my question is, why those indexes are used? I the second query (SELECT TOP 10 id FROM ZIPCodes) wouldn't it be faster if the clusteder index was used? How the query engine chooses which index to use?

    Read the article

  • Syntax Problems of if Statement (php)

    - by MxmastaMills
    I need a little help with an if statement in php. I'm trying to set a variable called offset according to a page that I am loading in WordPress. Here's the variable: $offset = ($paged * 6); What it does is it loads the first page, which is: http://example.com/blog and $offset is thus set to 0 because $paged is referring to the appending number on the URL. The second page, for example is: http://example.com/blog/2/ which makes $offset set to 12. The problem is, I need the second page to define $offset as 6, the third page to define $offset as 12, etc. I tried using: $offset = ($paged * 6 - 6) which works except on the first page. On the first page it defines $offset as -6. SO, I wanted to create an if statement that says if $paged is equal to 0 then $offset is equal to 0, else $offset is equal to ($paged * 6 - 6). I struggle with syntax, even though I understand what needs to be done here. Any help would be greatly appreciated. Thanks!

    Read the article

  • Using PHP to populate a <select></select> ?

    - by Flins
    <select name="select"> </select> I want to populate the above tag with values from database. I have written php code up to this. while($row=mysql_fetch_array($result)) { } $row is fetching fetching correct values.. how to add it to the <select> please help... Am new to programming

    Read the article

  • Change DIV contents on SELECT change

    - by Ian Batten
    I'm looking for a method of how to change the contents of a div when an option on a select dropdown is selected. I came across the following: <script type="text/javascript" src="jquery.js"></script> <!-- the select --> <select id="thechoices"> <option value="box1">Box 1</option> <option value="box2">Box 2</option> <option value="box3">Box 3</option> </select> <!-- the DIVs --> <div id="boxes"> <div id="box1"><p>Box 1 stuff...</p></div> <div id="box2"><p>Box 2 stuff...</p></div> <div id="box3"><p>Box 3 stuff...</p></div> </div> <!-- the jQuery --> <script type="text/javascript" src="path/to/jquery.js"></script> <script type="text/javascript"> $("#thechoices").change(function(){ $("#" + this.value).show().siblings().hide(); }); $("#thechoices").change(); </script> This worked fine on it's own, but I want to use it with the following script: http://www.dynamicdrive.com/dynamicindex1/chainedmenu/index.htm When using it alongside this chainedmenu script, it just loads all of the DIV box contents at once, rather than each div option when a SELECT option is chosen. Any ideas on what I can use alongside this chainedmenu script to get different DIV contents to show for different SELECT options? Thanks in advance, Ian EDIT Here is a test page: http://freeflamingo.com/t/new.html

    Read the article

  • Unable to compare valuesfrom mysql in a prepared statement

    - by Cortopasta
    I can't seem to get this to connect to the database so that I can run my prepared statement. Does anybody have an idea what I've forgotten? private function check_credentials($plain_username, $password) { global $dbcon; $ac = new ac(); $ac->dbconnect(); $userid = $dbcon->prepare('SELECT id FROM users WHERE username = :username AND password = :password LIMIT 1'); $userid->bindParam(':username', $plain_username); $userid->bindParam(':password', $password); $userid->execute(); $id = $userid->fetch(); Return $id; } EDIT: I changed the SQL query from a SELECT FROM query, to an INSERT INTO query and it worked. WHat the heck is going on?

    Read the article

  • SQL (mySQL) update some value in all records processed by a select

    - by jdmuys
    I am using mySQL from their C API, but that shouldn't be relevant. My code must process records from a table that match some criteria, and then update the said records to flag them as processed. The lines in the table are modified/inserted/deleted by another process I don't control. I am afraid in the following, the UPDATE might flag some records erroneously since the set of records matching might have changed between step 1 and step 3. SELECT * FROM myTable WHERE <CONDITION>; # step 1 <iterate over the selected set of lines. This may take some time.> # step 2 UPDATE myTable SET processed=1 WHERE <CONDITION> # step 3 What's the smart way to ensure that the UPDATE updates all the lines processed, and only them? A transaction doesn't seem to fit the bill as it doesn't provide isolation of that sort: a recently modified record not in the originally selected set might still be targeted by the UPDATE statement. For the same reason, SELECT ... FOR UPDATE doesn't seem to help, though it sounds promising :-) The only way I can see is to use a temporary table to memorize the set of rows to be processed, doing something like: CREATE TEMPORARY TABLE workOrder (jobId INT(11)); INSERT INTO workOrder SELECT myID as jobId FROM myTable WHERE <CONDITION>; SELECT * FROM myTable WHERE myID IN (SELECT * FROM workOrder); <iterate over the selected set of lines. This may take some time.> UPDATE myTable SET processed=1 WHERE myID IN (SELECT * FROM workOrder); DROP TABLE workOrder; But this seems wasteful and not very efficient. Is there anything smarter? Many thanks from a SQL newbie.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >