Jump to content

michaellunsford

Members
  • Posts

    1,023
  • Joined

  • Last visited

Posts posted by michaellunsford

  1. if they're always in the same order, you could use preg_match_all() to grab the values in order.

     

    Assuming you've already grabbed the content and put it in a variable named $content.

    preg_match_all('/([0-9]{2,3}\.[0-9]{2})/',$content,$matches);
    print_r($matches);

    would return:

    Array
    (
        [0] => Array
            (
                [0] => 103.51
                [1] => 140.26
                [2] => 169.65
                [3] => 113.88
            )
        [1] => Array
            (
                [0] => 103.51
                [1] => 140.26
                [2] => 169.65
                [3] => 113.88
            )
    )
  2. there's a MySQL query on the back-end and PHP loops through it all to create an array. Once the Array is built, PHP loops through it to build the table.

     

    The table is a basic events calendar by location. columns are days of the week (for only seven days), rows are locations.

  3. In a dynamically built table, what might be a way to identify large groups of empty cells that are clustered together? The goal is to combine them with rowspan and colspan attributes and drop an image in the empty space.

     

    There will be some guesswork involved in calculating actual area -- but the big challenge to overcome first is identifying and combining blank cells across rows. Any ideas?

  4. So, I have

     

    SELECT * FROM `calendar` WHERE `DATE` >= '2012-12-04' ORDER BY `DATE` ASC LIMIT 0,30

     

    The database hits some 10,000 records to find out which ones are today or future, which can really clock the database. Is there a way to manipulate the query or database so that it knows not to hit all 10,000 records in the search? I'd rather not separate the main table into two different ones, but that's about all I can come up with. Other ideas?

  5. I've been working on this one for a while. It's a left-side ad that's supposed to stick when a user scrolls down. I've accomplished this by javascript changing the position:relative; to position:fixed; It works wonderfully on normal computer screens. However, if the screen is smaller than expected, say an iPhone, and the user "zooms" in to get a closer look at the content, that left-side ad spills over the content. This effect can be duplicated on a desktop by shrinking the window size and scrolling the page to the right.

     

    I tried putting the ad inside another div with position:static; or position:absolute; without success. That position:fixed; just doesn't seem to want to stay inside any container. So, how do I tell it (preferrably via CSS) to stay left of the main content of the page? Or, must the scroll process also be relegated to javascript?

     

    site is here: http://acadiana365.com

  6. There are two tables. One table has the generic description and such, the other has a record number from the previous table, and a date relating to that record. Now, there are some records in the first table that do not have any matching records in the second -- and those are the ones I want to isolate: how do I do that?

     

    For example:

    1st table:
    event:
      keyfield => 1
      name => Event Name1
      description => Some descriptive text, usually in html
    event:
      keyfield => 2
      name => Event Name2
      description => Some descriptive text
    event:
      keyfield => 3
      name => Event Name3
      description => Some descriptive text
    
    2nd table:
    event_date:
      keyfield => 0
      event => 1 (keyfield from `event` table)
      date => 2011-10-24
    event_date:
      keyfield => 1
      event => 3 (keyfield from `event` table)
      date => 2011-10-24

     

    I want to know that the event with the keyfield of '2' does not have a record in the `event_table` I can get it done one record at a time with a php loop -- but I'm thinking MySQL probably has a single routine that can accomplish this. Any idea?

  7. The idea is to have multiple categories represented as classes. Most divs will only have a single class (no big deal) but some will have multiples. When someone turns off one of the categories, the class will be marked as 'display:none;'. However, I want the div to remain visible as long as it retains at least one class that is visible.

     

    consider the following:

    <div class="cat3">1</div>
    <div class="cat2 cat3">2</div>
    <div class="cat2">3</div>
    <div class="cat1">4</div>
    <div class="cat1 cat2 cat3">5</div>

     

    If the user decides they don't want to see "cat 3" items, '.cat3' will be marked as 'display:none;' -- however, '.cat1' and '.cat2' will still be 'display:block;' Is the best way to do this to just make sure that all 'display:block' declarations are also declared "!important;" ? Am I on the completely wrong track? What do you think?

  8. If you want the overlay to appear on the click of something, then yeah... you'll have to use jQuery, or JavaScript if you're old fashioned like that.

     

    Not to fire the event -- but for layout. iOS devices don't support "position:fixed" -- the elements just appear at the bottom of the page (based on their appearing last in the html code).

  9. Yep, I should have thought of fixed -- it actually fixes a few glitches I'm having. Fixed seems to be a challenge for iOS devices, though. I guess I'd have to rely on jquery in that case, though. Right?

  10. pretty simple CSS thing I've seen done on a number of sites. You click an image, and a div "pops" up with a close "X" in the top right corner. Usually, the rest of the site behind the popup is masked with a 60% opacity.

     

    So, I built one and it works great -- except my background mask isn't working quite right. It's set to height:100% -- if the page has a scroll bar and the user scrolls down, the 100% high mask ended at the bottom of the screen (not the page). So, they can scroll past the mask.

     

    The masks I've seen out there just have jquery apply a specific pixel height to the mask. I'm curious if there's a CSS-only way to do this. So far, I've not been successful. Thoughts?

  11. I have sites hosted on one server, being backed up to another. When the one server fails, I'd like to automatically switch requests to the other server. They are not located in the same building or anything like that. I know I can setup multiple name servers, is that the preferred method to do fail-over? Make each hosting server its own name server so when it fails, the secondary name server takes over?

  12. simple math - you just need to specify the width instead of the height. Swap your newwidth and newheight variables. Carefully adjusting the calculation to use the other variable.

     

    <?php
    $newheight=700;
    $newwidth=($height/$width)*$newheight;
    $tmp=imagecreatetruecolor($newwidth,$newheight);
    ?>

    edit - make sure to switch the order -- put the "newheight" variable above the "newwidth" variable.

  13. Having a big problem right now with the right-side apostrophe. You know, that little ’ character: also known as ’ or &#8217; I don't know what the deal is, but when it's coming out of a MySQL database, php just doesn't display it properly (I get a question mark - and the w3c validator whines about utf-8 compliance). I've checked one of the problem records in phpMyAdmin but it's displaying correctly!!! So, there's something amiss in php_fetch_assoc or something. (btw, if you care, the MySQL field collation is utf8_general_ci)

     

    So, I'm thinking I could just convert it to an entity before I send it to MySQL, and all will be right in the world. Enter experiment:

     

    htmlentities will convert it, right?

    <?php echo htmlentities("’"); ?>

    well, not so much. It returns "â??" -- that's actually creating three characters from one. And what's with those trailing question marks? Well, maybe htmlentities sister will treat it better.

    <?php echo htmlspecialchars("’"); ?>

    Nope, she returns the unmodified ’ character -- which is exactly what I sent. That's no good.

     

    Sooo, I tried making my own:

    <?php
    $str="Hello there, it’s all you!";
    echo preg_replace_callback("/[\x80-\xFF]/",create_function('$matches','return "&#".ord($matches[0]).";";'),$str);
    ?>

    guess what? It creates this mess: Hello there, it’s all you!

    Hello there, it&#226;&#128;&#153;s all you!

    That's three characters for the price of one - I bet this is what htmlentities() was doing.

     

    Okay, I'm officially stumped. Short of using str_replace("’","'",$variable) -- what's a body to do?

  14. I'm trying to pull a list of projects in the order that they were last updated. There are a few tables, but I thought to just query the updates table so I can sort by the last updated item. I thought it was pretty simple stuff, but I just can't seem to get the query right. Any help or insights would be grand. Here's what I've tried so far:

     

    //This works great except that there are multiple updates per project - so I get loads of duplicates.
    "SELECT `project`,`date` FROM `table` ORDER BY `date` DESC"
    
    //This returns exactly what the previous query does
    "SELECT DISTINCT(`project`), `date` FROM `table` ORDER BY `date` DESC"
    
    //This returns rows with the wrong date (not sorting by date before grouping), and thereby is in the wrong order
    "SELECT `project`,`date` FROM `table` GROUP BY `project` ORDER BY `date` DESC"
    
    //This one says "you have an error in your mysql syntax"
    "SELECT `project`,`date` FROM `table` ORDER BY `date` DESC GROUP BY `project`"

     

  15. I've been hacking on this for days and I just can't get the right google search to find the answer.

     

    Basically, I want to move a map marker after the map initialization function runs. The marker variable is local to the function, so I get "map.marker1 is undefined" in firebug. So, I add a global "var marker1,map;" and still the error persists.

     

    In the example below, the panTo works fine in the map, but the marker doesn't.  :confused:

     

    <script type="text/javascript" src="/ads/jquery-1.5.min.js"></script>
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
    <script type="text/javascript">
    var map;
    var marker1;
    $(document).ready(function() {
    	initialize(30.2240897,-92.0198427);
    	setTimeout('map.panTo(new google.maps.LatLng(30.22,-92.01));',5000);
    	setTimeout('map.marker1.setPosition(new google.maps.LatLng(30.22,-92.01));',5000);
    });
    function initialize(thelat,thelng) {
    	var latlng = new google.maps.LatLng(thelat,thelng);
    	var myOptions = {
    		zoom: 12,
    		center: latlng,
    		mapTypeId: google.maps.MapTypeId.ROADMAP
    	};
    	map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
    	var myLatlng1 = new google.maps.LatLng(thelat, thelng);
    	var contentString1 = 'test marker';
    	var marker1 = new google.maps.Marker({
    		position: myLatlng1,
    		map: map,
    		title: contentString1
    	});
    	var infowindow1 = new google.maps.InfoWindow({
    		content: contentString1
    	});
    	google.maps.event.addListener(marker1, 'click', function() {
    		infowindow1.open(map,marker1);
    	});
    }
    </script>
    <div id="map_canvas" style="width:auto; height:90%;"></div>

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