Jump to content

biggieuk

Members
  • Posts

    159
  • Joined

  • Last visited

Posts posted by biggieuk

  1. Hi all,

     

    I have a WYSIWYG in my CMS which the client has somehow managed to miss the opening and closing <ul></ul> tags from list items.

     

    What's the best way to programmatically add the <ul> and </ul> to the beginning and end of a set of <li> items which don't already have the <ul></ul> tags present?

     

    Thanks for your help.

  2. Hi,

     

    What format is your expiry date stored as in the database?

     

    If it's a date field you could just ORDER BY item_name, expires ASC

     

    this will first order by item_name then by expiry date starting with the most recent to expire.

     

    SELECT item_key, expires, item_id, item_img, name, COUNT(item_name) 
    FROM items 
    WHERE owner_id = '$id' AND status = 'Av' AND type = 'Food'
    AND expires >= DATE() 
    GROUP BY name 
    ORDER BY item_name, expires ASC
    

     

    This will only return items that have yet to expire and will be ordered by the first to expire.

     

    Depending on how your expiry field is structured:

     

    DATE() returns the date without time

    NOW() returns the current date & time

  3. I think the best way would be to firstly create the 2 new tables in your db.

     

    Then write a PHP script that takes all of your table data into an array. 

     

    You can then loop through each array item and INSERT specific columns into the correct table. You could also put an IF statement in your PHP to check for residential or business and insert the correct address.

     

    ;)

  4. Thanks for your replies.

     

    Doesn't seem to have worked however.

     

    cssfreakie - I need the menu items to fill the whole width of the #frame div, Is that what you are seeing?

     

    Thanks

  5. Hi all,

     

    I have a navigation that looks like this:

     

    http://jsfiddle.net/eyQnA/

     

     

    I am trying to get this to fill the widthof the #frame. I could set a width for each menu item but it is going to be dynamic so I'm not sure of the number of items.

     

    Is there a way to do this CSS only? 

     

    Also the menu seems to be broken in IE6, each list item takes up the whole width of the #frame instead of floating left.

     

    Thanks for help with this.

  6. Hi all,

     

    I have a booking system which stores different prices for different time periods.

     

    For instance:

     

    2011-06-10    -    2011-06-20  = £100

    2011-06-21    -    2011-06-30  = £200

     

    I have a date range:  ( 2011-06-15  -  2011-06-25  ), which is half way between both of the above ranges.

     

    What is the best way to query the database to get a total price for the supplied date range.

     

    I was using:

     

    SELECT id,start,end,rate,request FROM `pricebands` 
    WHERE ((start >= '$start' AND start <= '$end') 
    OR (end >= '$start' AND end <= '$end')
    OR (start >= '$start' AND end <= '$end')
    OR (start <= '$start' AND end >= '$end'))
    GROUP BY request ORDER BY request ASC
    

     

    but obviously grouping by 'request' (1 or 0) will not return the prices correctly. I thought about looping through each day and returning it's price then calculating but this seems excessive.

     

    Any ideas?

     

  7. Hi all,

     

    I have a multi-dimensional array looking somewhat like the following:

     

    Array
    (
        [0] => Array
            (
                [id] => 853
                [title] => item 853
                [price] => 17.99            
                [createdtime] => yyyy-mm-dd 00:00:00 
            )
    
        [1] => Array
            (
                [id] => 854
                [title] => item 854
                [price] => 11.99            
                [createdtime] => yyyy-mm-dd 00:00:00 
            )
    ...
    

     

    I need to re-order this array so that any items with the 'createdtime' within a month from todays date are at the top, followed by all of the other items in the original order.  I would usually amend the sql but I need to do this with the array.

     

    What would be the best way to do this? I found array_multisort but im not too sure how to adapt this to my needs.

     

    Thank you for any help with this!

     

  8. Hi all,

     

    I have a background image which I would like to animate as a 'pulse' effect using CSS3. Is it possible to animate the background image only ans not the container div?

     

    I would usually use this code but it will only scale the div not the bg image.

     

    @-webkit-keyframes pulse {
    from {
    	-webkit-transform: scale(1.0);
    	opacity: 0.75;
    }
    50% {
    	-webkit-transform: scale(1.1);
    	opacity: 1.0;
    }
    to { 
    	-webkit-transform: scale(1.0);
    	opacity: 0.75;
    }
    }
    
    .pulse:hover { 
    -webkit-animation-name: pulse; 
    -webkit-animation-duration: 0.5s; 
    -webkit-animation-iteration-count: 10; 
    }
    

     

    Any ideas?

  9. Im guessing my description wasn't too good.

     

    I'm currently having to delete all records with the matching servicesid then input all the selected id's.

     

    There must be a cleaner way than this?

     

    I would normally try and perform an update and check if any rows were affected before inputting but this also requires a unique ID which I am not passing into the query.

  10. Hi,

     

    Looking for some help with this slight specific mysql query.

     

    I have a table `services` which looks something like:

     

    id

    servicesid

    articleid

    1

    5

    10

    2

    7

    20

    3

    5

    16

     

    This is used so that i can return all of the articles tagged to a specific service (using serviceid).

     

    My ui has the articles selectable as checkboxes.

     

    What is the best way to skip the rows that have not changed, delete the rows that have been deselected and insert new rows for newly selected checkboxes?

     

    An 'ON DUPLICATE KEY' command will not work as there serviceid & articleid can be used more than once?

     

    Thanks for help with this. :confused:

  11. Hi, bit of a confusing one.

     

    I have dates stored in the database table bookings, fields 'start' and 'end' (YYYY-MM-DD)

     

    I then have two dates which the user has selected (YYYY-MM-DD)

     

    I need to return the id of all rows where the users selections are not booked in the database if that makes sense?

     

    Basically it's cheking to see which rooms are not booked already and returning them.

     

    Thanks.

  12. It's ok, I did this myself eventually.

     

    // Calendar
    $cal = array();
    $uid = 0;
    
    // Current date & end date
    $curr_date = date('Y-m-d');
    $end_date =  date("Y-m-d", strtotime($curr_date . "+12 month"));
    
    // Loop through year
    while (strtotime($curr_date) < strtotime($end_date)) {	
    
    // Set variables for new date
    $curr_month_name = date('F', strtotime($curr_date));
    $curr_month = date('n', strtotime($curr_date));
    $curr_year = date('Y' , strtotime($curr_date));
    
    $start_day = mktime(0, 0, 0, $curr_month, 1, $curr_year);
    $start_day_number = date ( 'w', $start_day );
    $days_in_month = date ( 't', $start_day );	
    
    $trow = 0;
    $blank_days = 0;
    
    $blank_days = $start_day_number - 1;
    
    if ( $blank_days < 0 ) {
       $blank_days = 7 - abs ( $blank_days );
    }
    
    // Prefix blank days
    for ( $x = 0 ; $x < $blank_days ; $x++ ) {
       $cal[ $curr_month ][ $trow ]['num'] = null;
       $trow++;
    }
    
    for ( $x = 1 ; $x <= $days_in_month ; $x++ ) {	 
       // Output ID
       $cal[ $curr_month ][ $trow ]['id'] = $uid;		  
       // Output Day
       $cal[ $curr_month ][ $trow ]['num'] = $x;	
       // Output YYYY-MM-DD
       $cal[ $curr_month ][ $trow ]['ts'] = $curr_year."-".$curr_month."-".sprintf('%02d', $x);
       
       $uid++;
       $trow++;
    }
    
    // Append Blank Days
    while ( ( ( $days_in_month + $blank_days ) % 7 ) != 0 ) {
       $cal[ $curr_month ][ $trow ]['num'] = null;	   
       $days_in_month++;	   
       $trow++;
    }
    
    // Add 1 month to current date.
    $curr_date = date("Y-m-d", strtotime("+1 month", strtotime($curr_date)));
    }
    

  13. Hi,

     

    Thanks for your replies.

     

    I am using Smarty PHP engine to display a calendar from the current month up until the same month in the following year.

     

    I need to output this array in PHP so that i can use Smarty's templating scripts to output the data as i like.

     

    I have found i can loop through a range of dates using

     

    $curr_date = date("Y-m-d", strtotime("+1 month", strtotime($curr_date)));

     

    to add a month onto the date each iteration.

     

    I am unsure as to how I can find out what day the month starts on and output this into an array.  :confused:

     

    I have attatched a sample of the mini calendar I am going for.

     

    [attachment deleted by admin]

  14. Hi all,

     

    I've been trying to find a simple script that can output an array of months within a given year which each contain the days for that month.

     

    Something along the lines of this:

     

                [1] => Array
                    (
                        [0] => Array
                            (
                                [num] => 1
                                [ts] => 2011/08/01
                            )
    ....
    

     

    1 being the month (jan)

    0 is the day (which contains the day & full date)

     

    Does anybody know of a script that does something along these lines as all the ones i have found seem over compliated and are outputting into tables whereas i only need this as an array?

     

    Thanks!

  15. Hello,

     

    I am attempting to develop a personal project that can store details (and maybe a google map pin location) of shipwrecks around the coast of an island.

     

    This project would require:

     

    - The ability to enter details whilst on or offline.

    - Store the details to a database.

    - To be used on multiple computers.

    - Eventually the details will be available to my iPhone whilst out and about.

     

    I am a php web developer so would ideally like this to be browser based (PHP /MYSQL)  but then I would not be able to enter the details whilst offline?

     

    Can anybody suggest any ideas/ methods I can use to carry out this project?

     

    Thank you.

  16. Hi all,

     

    I currently have two sites (A, B), both running on Smarty PHP Engine and with seperate databases. 

     

    I need to merge these sites together so I am trying to put all the files from A into a /forms/ folder on B.

     

    My problem comes when accessing the /files/ folder as all the links start with a forward slash /.

     

    Now to get this displaying properly & js working I can just remove the slash from all links however any sub pages will not reference these files correctly.

     

    Is there a quick fix for this so that I can easily move a site to a subdirectory and not have to mess around so much?

     

    thanks

  17. Hi all,

     

    I just need clarification on a mod_rewrite issue im having.

     

    I currently have links like so:

     

    www.website.com/12/blah-blah-blah

     

    which are already being re-written from:

     

    www.website.com/index.php?id=12 (blah-blah-blah is just random useless text to make it look pretty)

     

    Is it possible to remove the 12 part using mod_rewrite or am i going to need some sort of redirect page inbetween?

     

    Thanks for your help!

  18. Hi all,

     

    I have a list of months in the following format:  Dec 09, Jan 10, Feb 10 etc...

     

    I need to perform an sql query to return all data for that current month, How can i convert that date into the following format:  2010-02-01 (Y-m-01)?

     

    Thanks.

  19. Hi all,

     

    This may not be possible but I have serialized arrays in a table services, field related.

     

    I am currently returning this array based on an id and unserializing the data. Another query then returns each title from the articles table where the ids corresponds to the unserialized array.

     

    I am wondering if it's possible for me to query the articles table based on the serialzed array in the services table?

     

    thanks for help with this.

     

     

×
×
  • 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.