Jump to content

Omzy

Members
  • Posts

    314
  • Joined

  • Last visited

    Never

Everything posted by Omzy

  1. I fixed this using: session_cache_limiter('private_no_expire, must-revalidate');
  2. Hi, I need a preg_match for the following criteria: - no leading or trailing white space allowed - only alphanumeric characters and spaces are allowed (no full stops, commas apostrophe's, explanation marks, quotes, etc) - only one space allowed between each word (if there is more than one word) Thanks.
  3. I have a HTML dropdown list which is populated from a MySQL table. I use an auto-incremend ID field. I have also got a sort_order field. I would like to be able to specify the exact order that entries should appear in the dropdown list. Specifically I need some functionality that does the following two things: 1) If I change the sort order of a record to for example "4" then the existing record with sort_order 4 becomes 5, sort_order 5 becomes 6 and so on. 2) If I change the sort order of a record to for example "4" and there is currently no record with sort_order 4, then no other records will be updated.
  4. public function getEventTypes() { return array( 1=>array('Exhibition', 1), 2=>array('Wedding', 1), 3=>array('Business', 1), 4=>array('School Trip', 0), 5=>array('Birthday', 0), 6=>array('Concert', 1), 7=>array('Sporting Event', 1), 8=>array('Training', 0), 9=>array('Conference', 1), 10=>array('Other', 1), ); } I now want to generate a new array from this array as follows: 1) must retain the existing key 2) must be single dimensional and the value of each element will be value[0] 3) must only contain the array elements where value[1] = 1 So for example the generated array should be as follows: public function getActiveEventTypes() { return array( 1=>'Exhibition', 2=>'Wedding', 3=>'Business', 6=>'Concert', 7=>'Sporting Event', 9=>'Conference', 10=>'Other', ); }
  5. OK I've tried this, the thing is that the explode() function creates an array with it's own numerical indexes and that makes it more difficult to format the data. I put the data in to a string ($towns) and then did the following: $townarray=explode(",", $towns); $townstring=implode(",", $townarray); $newtownarray=explode("=", $townstring); foreach($newtownarray as $key=>$value) { echo $value; echo "\n"; } I think there is obviously an error in this and I can't figure out how to do it..
  6. I've got some data which I need to populate into a database. Currently it is the following form: East Kilbride = 10, Ellesmere Port = 1, Worksop = 6, Worthing = 4, Wrexham = 11, Yeovil = 3, York = 8, (that is just a sample of the data, there are about 400 rows) So it's basically like a key & value format, I can of course do a find&replace on the equals symbol to get the => operator and convert the data in to an array, but the main diffculty is to get the keys/values enclosed in single quotes. The idea is to build an mysql insert statement so that I can input all the data in to one of the tables. How would I go about doing this?
  7. Basically I construct the SQL query based on what fields need updating. If the user only needs to update one field then there isn't much sense in overwriting all the other fields with the same data. Unless you know of a more elegant way to achieve the same behaviour?
  8. Sorry I should have been more clear - there is one checkbox per field (5 fields in total).
  9. I have a form with some input fields; all fields are disabled by default, so this means those fields do not get posted unless a tickbox is ticked to enable them. Also in the form is a hidden field "userid". I want to check if "userid" is the ONLY field in the $_POST array - if yes then I can just redisplay the form.
  10. I currently use the following rule to rewrite .php to .htm RewriteRule ^(.*)\.htm$ $1.php I now want to change this so that it rewrites .php to .html, but also add another rule to redirect any existing .htm urls to .html (must be a search engine friendly/301 redirect).
  11. I like jQuery, but one thing I don't like is the vast CSS library included with it. There's so many styles that are overriding parent styles and so on. I like to keep my CSS as simple as possible and although splitting up CSS is good practice, I don't particularly like the idea of applying so many different classes to an element or overriding styles more than once. The thing with jQuery is that all the components share a 'base' css file (jquery.ui.theme.css). This file has shared styles such as .ui-widget and .ui-state-default. The problem I'm having is that if I want to style an individual component I inevitably have to modify one of the shared styles, which subsequently affects other components. How can I, for example tell jQuery Tabs to use ONLY css property ID #tabs instead of using the classes "ui-tabs ui-widget ui-widget-content ui-corner-all"?
  12. Hi there and thanks! Yes I should have mentioned, there are multiple main categories! I just wanted to reduce the code and have only one loop to be honest.
  13. Here is my multi-dimensional array: $subcats=array( 'lighting-effects'=>array( 'light-shows'=>array('Light Shows', 'Wedding Light Shows'), 'sound-systems'=>array('Sound Systems', 'Wedding Sound Systems'), 'visual-displays'=>array('Visual Displays', 'Wedding Visual Displays'), 'fireworks-pyrotechnics'=>array('Fireworks/Pyrotechnics', 'Wedding Fireworks/Pyrotechnics'), 'star-cloths'=>array('Star Cloths', 'Wedding Star Cloths'), 'mist-generators'=>array('Mist Generators', 'Wedding Mist Generators'), 'virtual-flames'=>array('Virtual Flames', 'Wedding Virtual Flames'), 'confetti-canons'=>array('Confetti Cannons', 'Wedding Confetti Cannons'), ), ); I want to run a foreach loop on the 'lighting-effects' array keys (light-shows, sound-systems, etc). Currently I do it like this: foreach($subcats as $index1 => $value1) { foreach($value1 as $index2 => $value2) { // processing here } } But I'm wondering if this is a long winded way of doing it/is there a quicker way?
  14. Thanks mjdamato. So now how do I go about outputting the data to my requirements?
  15. Here is my Categories array: $cats=array( 'decorations'=>array('Decorations', 'Asian Wedding Decorations'), 'flowers'=>array('Flowers', 'Asian Wedding Flowers'), ); Currently I print this out to to a form on the page as follows: foreach($cats as $index => $value) { echo ' <input type="checkbox" name="selection[]" value="'.$index.'" id="'.$index.'" /> <label for="'.$index.'">'.$value[0].'</label> '; } So this is all fine and dandy. Now I also have a Subcategories array, which uses the first element of its array to join with the Categories array: $subcats=array( 'balloons'=>array('decorations', 'Balloons'), 'banners'=>array('decorations', 'Banners'), 'roses'=>array('flowers', 'Roses'), 'tulips'=>array('flowers', 'Tulips'), ); So basically I would like to print out the subcategories of the parent category in square brackets, for example: Decorations [balloons, Banners] Flowers [Roses, Tulips]
  16. Just a quick question - should the the ampersand (and other special characters) be stored in it's encoded form (e.g. &) in the database, or should it be stored in its 'raw' form and encoded in the script as and when required?
  17. Basically I specify Arial as the global font (body tag), Firefox comes across an element that uses a font that is not available on the system. It consequently renders the element using the "default font" setting in the browser options. IE will render the element in the global font - this is the behaviour I want.
  18. In my CSS stylesheet I have: body { font-family: Arial } This is like a global rule, i.e. any elements without a font specified should render in Arial. Now I have some elements with font "Century Gothic". For example: h1 { font-family: Century Gothic } This font is not always available on a user's PC. In this case, when using IE (all versions) what happens is that the Arial font is rendered instead for those elements (taken from the 'body' rule). In Firefox however, this does not happen. Instead it renders in the 'Default Font' setting as specified in the browser options. The way round this of course is to specify Arial alongside Century Gothic for those elements. But this is not my preferred way of doing it. How can I make it always fallback to Arial font when the desired font is not available?
  19. I want to pad a string with the | (pipe) character at the beginning and end of the string. I tried str_pad() but that won't work. I can obviously add the character in manually but was just wondering if there was a function out there that could do it.
  20. How do I insert data from one table to another?
  21. How do I insert data from one table to another?
  22. I have field ID in my table (not auto-incremented), what I wish to do is set the ID field of the first row to 200, and then add 1 to the ID on every next row.
×
×
  • 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.