Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. The reason what you tried doesn't work is because of the space between th and .formheader. With the space it is looking for an element with class .formheader that is a descendant of a th element, for example: <th><span class="formheader">Blah</span> Blah</th> In order for it to seek a th which itself has the .formheader class you need to remove the space, eg: table th.formheaderAs mentioned though, using the table tag, and a th prefix on the class is likely unnecessary unless you need that level of specificity to overcome previous rules.
  2. The reason why is because setting an item to position: absolute; removes it from the flow, so your sun is no longer considered to be a child of your container. It gets put into the flow of the nearest positioned element, or the body if no other. By making your container position: relative; it becomes the nearest positioned element and so the sun continues to be a child of it and the overflow works properly.
  3. In my case it was the real table that is set to latin1, so I assume the constants were utf8. That makes sense as converting the constant to latin1 fixed the issue. I don't know if the server version makes much difference, it is probable Barand's test was on a server that defaults to utf8 when creating a table so there was no conflict.
  4. Yea I just tried on my server, +-------------------------+ | version() | +-------------------------+ | 5.5.34-0ubuntu0.13.04.1 | +-------------------------+ and got a similar message. The following fixed it: SELECT tmp.string FROM ( SELECT CONVERT('a' USING latin1) AS string UNION ALL SELECT 'b' UNION ALL SELECT 'c' UNION ALL SELECT 'd' ) AS tmp LEFT JOIN t1 ON (t1.T1col = tmp.string) WHERE t1.T1col IS NULL;
  5. Are you just getting an empty result set with the strings or are you getting some kind of error?
  6. Your javascript file has an error in it, right here: with (window.document.frmAddProduct) { } else if (isEmpty(txtName, 'Enter Product name')) { return; } else { submit(); } } Because of that, the entire file cannot be loaded and none of it's functions will be defined. You need to fix that error then it will define the function. What you are doing is a poor practice also. There is no need to involve Javascript here as all you are doing is linking to another page. Just simply do: <a href="index.php?view=modify&club=5">Modify</a>
  7. You would have a separate row for each employee and item combination. So if three people all selected ItemA you'd have three rows: employee | ItemID ------------------- Alice | ItemA Billy | ItemA Cassy | ItemA
  8. SELECT DISTINCT student_id , DATE(swipe_in) FROM attendance That should get you a list of the students and the date when they swiped in. The DATE function extracts only the date portion of the datetime value so two swipes on the same day but different times would still be filtered to a single entry as a result of the DISTINCT operation. If you need to display the exact time they swiped in and not just a yes/no for the date, then you could use group by on the date portion: SELECT student_id , MIN(swipe_in) FROM attendance GROUP BY student_id , DATE(swipe_in)
  9. I don't have any direct experience in this area, so I can't really comment on what works or doesn't work. There are some guidelines about creating accessible documents you could check into for suggestions. What I would suggest is that you get some of the commonly used screen reading software and simply try various methods to see how well they work. Trying various software would best let you figure out how it handles things like dynamically added content. At minimum you should probably set focus to the first field which has an error by calling it's .focus() method. I would guess that should trigger the label for that field to be read again along with any text you may have added.
  10. No, but that's also irrelevant to what I was talking about. If you read what I wrote: Ie, querying the database directly using PHPMyAdmin or the MySQL command line, not with your scripts. When you do that you don't get the chance to format your timestamps with PHP, you just see the raw number. If you use a proper DATETIME column you'd see a human-readable date not some giant number. When it comes to actually outputting the dates on your pages for end users, as has been said before, you are not stuck with the default YYYY-MM-DD HH:mm:ss DATETIME format. You can convert it to whatever format prior to display. Conversely, you can also convert whatever format you want into the YYYY-MM-DD HH:mm:ss format when asking for date/time inputs on your site. Doing something in an ill-advised way just because the proper way "looks weird" is a poor excuse. We never said that using a timestamp is always wrong. We said that storing them in your database is wrong. Appending a timestamp to a url is perfectly valid and has absolutely nothing to do with storing a timestamp in a database. That said, if you append the timestamp all the time, you are also destroying any possible caching of the stylesheet, which is also bad. Most of the time your stylesheet isn't going to be constantly changing so there is no point in people downloading a fresh one every time they load the page. By adding the current timestamp on every page load you'll force people to download the stylesheet on every request, wasting time and bandwidth. If you want to add a timestamp to aid with detecting changes, you should add one that only changes when the file changes, such as the file's modification date timestamp as returned by filemtime. Then that's your choice, I can't force you to change anything. I said if possible because I realize sometimes something is either out of your control, or you're already so deep in the current design that it's not worth changing. What I said was simply a strong suggestion, not a demand. It's not like I am going to stop helping you (or anyone else) unless you change it, but you'll likely hear the same suggestions in the future if you post other threads involving timestamps stored in your database. Not as a result of some effort to force you to change, but rather just because timestamps are ill-advised and likely we won't remember having already told you before. When I started also stored every date as an INT column with a timestamp in it. It seemed like it was easier to deal with in the PHP code and there is some truth to that. However once I actually took the time to learn the database-provided date functions I saw the value of using proper DATE or DATETIME column types. A lot of what I previously did in PHP was easier to do and more efficiently done in the SQL using the date functions. I rarely have to do much date manipulation in PHP anymore, and for those times it is necessary it is easy to convert a DATETIME value to a timestamp using either the DateTime class or strtotime function. There are many benefits to storing the data in a properly typed column, and the learning curve is fairly minimal.
  11. That's a silly way to store birthdays as well. You should store them in a single DATE column which would be in the YYYY-MM-DD format. You can display the birthday in whatever format you want, or three-input method when asking for the birthdate, but the data itself should be stored in a single column of the DATE type. This way you can use all the aforementioned datetime functions to do things like calculate a persons age or query for upcoming birthdays. As for your post timestamps, those would be better stored as a DATETIME value as well. In addition to allowing the use of the aforementioned datetime functions, it makes the data readable in the event you need to manually query the database for some reason. Say you were debugging a query and the post time is part of the selected columns/conditions, which is easier to read: +--------+---------------------+ | name | postedWhen | +--------+---------------------+ | kicken | 2014-01-30 21:04:24 | +--------+---------------------+ or +--------+------------+ | name | postedWhen | +--------+------------+ | kicken | 1391133864 | +--------+------------+ Having the data stored as a datetime would allow you to do your 5-second check right in your query when selecting posts. eg: SELECT name , postedWhen , CASE WHEN postedWhen > DATE_SUB(NOW(), INTERVAL 5 SECOND) THEN 1 ELSE 0 END as isNew FROM posts Bottom line is storing the data as a unix timestamp is wrong, and you should change that if at all possible.
  12. You need to get the ID generated when you insert your answer and then pass that to the questions insert. You can get the last generated ID using mysql_insert_id. You should also start moving away from the mysql_* functions and re-writing your code to use either PDO (my recommendation) or MySQLI
  13. When you change it to 5 you get 15 because the value of your total field is 10. 10 + 5 = 15. It's adding just fine. I'm assuming what you intended is for it to always use the original total value (ie when adding. If that is the case, you should be able to get that value using the .defaultValue property rather than the .value property. .defaultValue contains whatever value the control was initialized with using the value="" attribute in the HTML. Lastly, whenver you post your code here, make sure you wrap it in tags so that it is formatted nicely and preserves indentation.
  14. Thanks, I had seen some of the override ability previously, though not that particular page. It seemed like a bit much to have to create and register a bundle just to change themes though, and didn't seem to fit well with what I had thought. I may re-visit the idea however. I'll keep plugging away at a few ideas and post back with whatever I decide to go with later.
  15. Before you do your INSERT query, run a SELECT to see if the user has already posted an item that day. If so then don't do the INSERT and show an error message.
  16. Aye I just found that and was coming back to edit my post. My initial search lead me to the InnoDB and Foreign Key constraints page which made no mention of an index except on the reference table.
  17. Foreign keys are not automatically indexed. You still would have to add your own index to the column if desired. The benefit of having a real foreign key definition is integrity checking. Also know that a real foreign key definition only exists if you use the InnoDB engine. MyISAM does not support foreign keys so their definitions are ignored when creating a table.
  18. I haven't taken apart too many laptops, and the few I did I wasn't really paying that much attention to things like the mic and such. I'd suspect however that an issue you'd probably run into is various components all using the same connector to the main board. For instance a lid with the display, webcam, and mic may use a single ribbon cable to connect to the motherboard. As a result disconnecting that cable would disconnect your display as well. You could try and single out which pins control which devices and remove them but you run the risk of permanent damage if you get it wrong.
  19. You use the same format as your other options. CURLOPT_PROXY => $this->getProxy() That or add the $options[CURLOPT_PROXY] = $this->getProxy(); on the next line by itself.
  20. So I started using Symfony a few weeks back, figured I should probably learn one of these frameworks rather than always do things custom. So far I like it, but it's been a bit of a learning curve from how I've typically done things. One thing I'd like to do with my project is setup a system for using themes on the site, but I've not yet figured out how to do so in a manner that I like. I'm hoping maybe someone with more Symfony experience can shed some light on how best to approach this. I'll give a quick rundown of how I think I'd like for things to work. Any suggestions are welcome. What I'd like to be able to do is set a path to a directory which contains all the themes. Installing a new theme should be as simple as just extracting a zip file into this directory. The active theme would be controlled through a configuration parameter. So essentially when someone sets up the software, they would just add a couple lines to their parameters.yml file, for example: parameters: themes_root: %kernel.root_dir%/../web/themes active_theme: default A theme would consist of a few twig templates for various types of pages (or snippets). The controller views would extend these templates as necessary. The theme's templates should be able to extend other templates within that theme as well. For example a theme may have a base template and various pages would extend that. My initial thought for how to do all of this was to create a twig extension to add a function which would resolve the path to a theme template. For example my view would do: {% extends ThemePath("simplepage.html.twig") %} {% block Content %} blah {% endblock %} The ThemePath would use the parameters to construct the full path to the twig template, for example D:\site\web\themes\default\simplepage.html.twig. I completed this part but ran into my a snag with Symfony complaining that the template name passed to extends was not in bundle:section:template.format.engine format. I managed to work around this by replacing the default name parser to allow absolute file paths or the Symfony format. This is working all well and fine but there are a few things I don't like about this setup: It feels ugly to me. Seems like there should be a better way than this. The theme files need to use the ThemePath function as well if they use extends or similar. Ideally this would be unnecessary. Any comments/thoughts/suggestions/questions are welcome.
  21. The object you pass to $.ajax can contain a data key which is the data to be posted to the script. You need to set this to the value you need to pass. Such as: $.ajax({ //create an ajax request to load_page.php type: "GET", url: "php/contact.php", data: { id: $('#idcontact').val() }, dataType: "html", //expect html to be returned success: function(response){ $(".contacttext").html(response); //alert(response); } });
  22. 'as' generally indicates that you are aliasing something. In the context of foreach it indicates that the items in the array will be assigned to the given variables within the loop body. Basically what that structure says in english is: For each item in $array, assign the item's value to $var and execute the instructions below. => indicates a key and value pair. On the left side of => is the key, and on the right is the value. So what that line is saying in english would be: For each item in $array, assign the item's key (aka index) to $var and the item's value to $value and execute the instructions below. => may also be used when creating an array, such as $array = array( 'key' => 'value' //, 'more' => 'pairs...' );
  23. No, what you want is not possible in a single query. It also sounds like a terrible database design. Why are you wanting to do this? What problem are you trying to solve with this design?
  24. strpos: You're calling it with the arguments in the wrong order. You're checking to see if the string 'test.ezvaluation.com' exists within the string 'test'.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.