-
Posts
468 -
Joined
-
Last visited
Never
Everything posted by chiprivers
-
I am producing a php script which will include some AJAX in the resultant web page, which will send some data to another php script for processing. If I create a php session in my original script, will the same session be accessed by the second script being run by the AJAX or will it create a new session?
-
sorry, that was a typo - should be YYYY-MM-DD HH:MM:SS
-
My php script is working with dates in the format 'YYYY-DD-MM HH:MM:SS'. I want to pass this into my javascript, at which point I will need to convert it to a date object. I have tried using Date.parse() but it does not like the format of my date string. What is the simplest way to turn this date string into a date object? NB I would rather do this within the javacript than as part of the php!
-
Thanks haku. I am familiar with the 'specifity' of css but I was wondering whether there was a way of overiding this? Whether there was a command that could be included within a declaration that would make it a priority over any other normally prioritised contradicting declarations.
-
Is it possible to make a CSS class take priority over any other conflicting declarations, irrespective of where the class is declared and the order in which it might appear?
-
some structured guidance for my first ajax please
chiprivers replied to chiprivers's topic in Javascript Help
Thanks for that gamesmstr, I will spend some time looking at that to see if I can get my head around it. Hopefully it will be easier to understand when applying it to my own project! -
How did I miss that? I knew it would be something simple! Thanks for that
-
I am having a real problem with some css! I am using php to dynamically add some css class declarations to the head of my page script. The following has been added within the head tags: <head> ... <style type="text/css"> .sts_unavailable { background-color: #C1C1C; } </style> ... </head> In this form the class is not having any effect on the subject elements. However, if I put exactly the same into an external style sheet, ie: ... .sts_unavailable { background-color: #C1C1C; } ... it works fine! I have gone over and over this and must be missing something really straight forward and simple! but what is it?
-
I have not used ajax before but I believe it is the tool I am looking for to make one aspect of my current project run smoothly. I have tried googling several ajax tutorials but I am struggling to get me head around how to do this. What I want to do is the following: I have a basic page php page with a table contained within a div <div id="dynamic_update"> <table id="results_table"> ... </table> </div> When the page first loads, the html for the table is sourced from a further php script using the required function. What I want to be able to do is use ajax to send some variables to the php script which generates the table code, process the provided variables, return some revised code for the entire table, and replace the existing table with the new one. I am happy with the general html, php and javascript/jquery elements of making this work, I just dont know where to start with the whole ajax part of it! Any guidance or a basic explanation of the various steps / actions would be much appreciated. I am sure I can work the rest out once I know the basics.
-
That has sorted it, it was down to the order in which my classes were declared in the style sheet. I have moved the .selected class to the bottom of the list and no the script is performing perfectly. Thanks for the guidance.
-
Unfortunately I can't give a link as I only have it running on my lapto - I am using the addClass jQuery function to add the class to the appropriate elements and I know it is working because I can see it in Firebug. Does the order in which the classes are listed within the class property determine their priority?
-
In the body of my html: <td class="status">...</td> <!-- all elements have the 'status' class 'hardcoded' in the html --> <td class="status faded">...</td> <!-- some elements have the additional 'faded' class added by the php script --> The css file linked to from within the head of the html contains the following: .status { // there is no background-color delaration within this style } .faded { background-color: #333333; } .selected { background-color: #7CAFF2; } There is then a jQuery script that will apply an additional 'selected' class to some elements on the client side, which in effect ends up with this: <td class="status selected">...</td> <!-- these elements will take on the background-color of the 'selected' class --> <td class="status faded selected">...</td> <!-- the background colour of these elements will stay as set by the 'faded' class -->
-
I think this is the best place to post the thread, however, those of you with jQuery experience may be better placed to answer it! I have a table in my script where all of the <td> elements have the class set to 'class1'. Some of these <td> elements then have an additional class set to 'class2' by the php script as it runs. I then want to be able to apply a further 'class3' dyanically using jquery upon certain events. .class1 has no background-color property .class2 has a background-color property .class3 has a different background-color property When the page loads, the background colour of the appropriate <td>s is showing correctly where 'class2' has been applied. However, when 'class3' is applied, the <td>s without 'class2' change correctly, but the background colour does not apply to those <td>s with a 'class2'. eg class="class1" -> there is no background colour displayed class="class1 class2" -> the background colour of 'class2' is displayed class="class1 class3" -> the background colour of 'class3' is displayed class="class1 class2 class3" -> the background colour of 'class2' is displayed I want background colour of class3 to be displayed
-
Is it possible to echo the query just submitted using mysqli->execute(); I am having trouble with a prepared statement which I know is working fine because I can copy and paste it straight in, replacing the ? with the required values and it works. I have echoed the $variables in my php script to ensure they are correct before carrying out the execute() but I am getting no rows returned. I am just wondering if there is a method for returning the complete query as it was run to ensure it is correct?
-
Perserverence is the key! I have managed to come up with the following query which appears to work: SELECT s.time, c.status, c.indicator AS s_indicator, c.available, r.indicator AS r_indicator FROM status AS s INNER JOIN (SELECT MAX(record_created) AS this_created FROM status WHERE contractREF = 1 AND date = '2010-09-10' GROUP BY time, contractREF) AS j ON s.record_created = j.this_created LEFT JOIN status_codes AS c ON s.status_codeREF = c.status_codeID LEFT JOIN resources AS r ON s.resourcesREF = r.resourcesID ORDER BY s.time All I had actually got wrong was one column name in the inner join on condition! :-\
-
In an earlier post I established I needed to use an INNER JOIN to ensure that I only pulled the most recent record from a table where there several duplicates but with different dates. I had that working but now I have tried to add the rest of the compelxities to the query, I can't get it right! I have the following tables: CREATE TABLE `status` ( `statusID` int(10) unsigned NOT NULL AUTO_INCREMENT, `contractREF` int(10) unsigned NOT NULL, `date` date NOT NULL, `time` time NOT NULL, `status_codeREF` int(10) unsigned DEFAULT NULL, `resourcesREF` int(10) unsigned DEFAULT NULL, `record_created` datetime NOT NULL, PRIMARY KEY (`statusID`) ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 CREATE TABLE `status_codes` ( `status_codeID` int(10) unsigned NOT NULL AUTO_INCREMENT, `status` varchar(50) NOT NULL, `indicator` varchar(10) NOT NULL, `available` int(1) unsigned NOT NULL, `record_status` int(1) unsigned NOT NULL DEFAULT '1', PRIMARY KEY (`status_codeID`) ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 CREATE TABLE `resources` ( `resourcesID` int(10) unsigned NOT NULL AUTO_INCREMENT, `resource_typesREF` int(10) unsigned NOT NULL, `indicator` varchar(5) NOT NULL, `stationsREF` int(10) unsigned NOT NULL, `record_status` int(1) NOT NULL DEFAULT '1', PRIMARY KEY (`resourcesID`) ) ENGINE=MyISAM AUTO_INCREMENT=131 DEFAULT CHARSET=latin1 The 'status_codeREF' and 'resourcesREF' columns in the 'status' table reference the 'status_codeID' column in the 'status_code' table and the 'resourcesID' column in the 'resources' table respectively. I need to extract 'time' from the 'status' table, 'status', 'indicator' and 'available' from the 'status_code' table and 'indicator' from the 'resources' table. The results should be limited to those where the 'contractREF' column in 'status' is equal ? and 'date' in 'status' is equal to ?. There may be multiple duplicate records which share the same 'contractREF' and 'date' values and these should be limited to returning only the record with the most recent 'record_created' value. The query that I have put together is: SELECT s.time, c.status, c.indicator AS s_indicator, c.available, r.indicator AS r_indicator FROM status AS s INNER JOIN ( SELECT MAX(record_created) AS current_record FROM status WHERE contractREF = 1 AND date = '2010-09-10' GROUP BY time, contractREF ) AS x ON s.time = x.current_record LEFT JOIN status_codes AS c ON s.status_codeREF = c.status_codeID LEFT JOIN resources AS r ON s.resourcesREF = r.resourcesID ORDER BY s.time ASC This query validates OK but does not return any records when I know there should be some if I had the statement correct.
-
Have you double checked your table name and column names are correct?
-
Thanks Keith. I has just come up with the same myself, just without the 'TRUE' bit, and it is working perfectly.
-
Well spotted Keith, such a silly mistake! It is at least now beign accepted as a valid query. However, as an extension to this question, I need to amend it so that instead of the values in the r.indicator column being equal to P, A, R, M or C, I need to see if the values contain these letters. I thought I could do this by just changing the 'P' to a '%P%' but this is not working. Any suggestions?
-
I have got the following SELECT query which is returning false: SELECT r.indicator FROM resources AS r WHERE r.stationsREF = 1 AND r.record_status = 1 ORDER BY CASE r.indicator WHEN 'P' THEN 1 WHEN 'A' THEN 2 WHEN 'R' THEN 3 WHEN 'M' THEN 4 WHEN 'C' THEN 5 ELSE 6 I know that it is the ORDER BY CASE syntax which is causing the problem because it works fine when I remove this part of the query, however the same syntax works fine on another similar query that I am using. Can anybody tell me what I need to change? If it is not obvious, I need to order by the r.indicator column where 'P' is listed first, 'A' second, 'R' third, 'M' fourth and anything else afterwards.
-
Not sure that in this case it will make any difference? The gmdate() function, which although date() is probably sufficient, is getting the current date and outputting only the date portion, and manually adding the 00:00:00 to the string. This part of the function is working fine, it is just that when I use strtotime() to turn the produced string into a timestamp, it is appearing to be an hour out. However, I have found that it might not be out!? I was checking the time stamp by putting it into an online timestamp converter to see what it converted it into but I think that may have been misleading! When I use my script to turn my produced timestamp back into a string, it appears to do what I want it to do. Whether it is right or not, I don't suppose it will matter so long as it converts back to what I want it to do?
-
I need to set two variables for use within my pages, one containing a date as a string in format 'YYYY-MM-DD HH-MM-SS' and another containing the same date as a timestamp. The date and time stored will take on the value passed in the url if available, else will be for the current date. The time should always be midnight at the beginning of the date. eg. $datestr = '2010-09-08 00:00:00' and $datestamp = '1283904000' Where a date is passed in the url, it will be in the format 'YYYY-MM-DD'. The problem I am having is getting an accurate timestamp. I think the trouble is connected to the handling of daylight saving time as it it always an hour out. What I have at the present is as below: <?php // ensure all date and time functions are relative to the correct timezone (UK) date_default_timezone_set('Europe/London'); // string holding selected / current date in format 'YYYY-MM-DD HH:MM:SS' $datestr = (isset($_GET['date']) ? $_GET['date']." 00:00:00" : gmdate("Y-m-d")." 00:00:00"); // int holding selected / current date as unix timestamp $datestamp = strtotime($datestr); ?> Can anybody give me a simple way of converting $datestr into $datestamp to ensure that this is always correct for my UK timezone, irrespective of whether we are in or out of daylight saving time?
-
I have started and restarted working on a current project several times, with varying approaches to handling the date and time. Because the project is very date/time orientated, I need to get this just right for it to work properly and efficiently. After struggling to get several bits to work as expected, I found the the timezone in my php.ini file was set to Berlin when I am in the UK. This has solved a couple of issues. However, before I get abck to the drawing board and decide on a final approach for this project, I am just interested in how other people handle dates and times in their scripts. Firstly, dates and times stored in a mysql database, should I use the DATETIME format in the database and convert to timestamp if required, or store as a timestamp in an INT column? Does either approach give a quicker response when searching or sorting by date/time? Now I have my php.ini amended to default to Europe/London timezone, do I need to use gmdate and gmmaketime etc to ensure daylight saving time is taken into account, or will this be done automatically? Any other advice regarding date and time handling before I start to restructure my design would be much appreciated. Thanks in advance.
-
I have not really ventured much past basic query statements before so please excuse me if what I am trying to do here is very simple. I have a table with columns including 'id', 'status', 'time', 'user', 'created'. There will be many records where the 'time' and 'user' columns have duplicate values but will have a DATETIME value in the 'created' column showing when the record was created. I need to pull all records from the above table where 'user' = $user, but if there are multiple entries with the same value in the 'time' column, only the most recent value should be returned. Could somebody please give me a SELECT statement for this?
-
Hi, I am relatively new to javascript and an even newer user of jQuery, so please excuse me if I am missing something really simple here. I have the following jQuery script in my page: $('.status') .click( function(e) { var clicked = $(this).attr('id'); clicked = clicked.split('_'); var click_ff = clicked[1]; var click_start = clicked[2]; var click_end = clicked[3]; var res = $('#su_res').val(); if ($('#su_ff').val() == "") { // if there is no existing selection // set form values $('#su_ff').val(click_ff); $('#su_start').val(click_start); $('#su_end').val(click_end); console.log('happy thus far!'); } else if ($('#su_end').val() - $('#su_start').val() != res - 1 || click_ff != $('#su_ff').val()) { // if there is more than one cell selected or different ff clicked // clear previously selected range var shade_start = $('#su_start').val(); while (shade_start < $('#su_end').val()) { var shade_end = shade_start + res - 1; $('#_'+$('#su_ff').val()+'_'+shade_start+'_'+shade_end).removeClass('selected'); shade_start += res; } // set form values $('#su_ff').val(click_ff); $('#su_start').val(click_start); $('#su_end').val(click_end); } else { if (click_start < $('#su_start').val()) { // set new start value $('#su_start').val(click_start); } if (click_end > $('#su_end').val()) { // set new end value $('#su_end').val(click_end); } } // shade selected range var shade_start = $('#su_start').val(); while (shade_start < $('#su_end').val()) { var shade_end = shade_start + res - 1; $('#_'+$('#su_ff').val()+'_'+shade_start+'_'+shade_end).addClass('selected'); shade_start += res; } }); Firebug is reporting that 'selecter is not defined', but I don't know what this means or where my error is! Can anyone help? If you need any explanation as to what I am trying to do with this script, please let me know. Thanks.