Jump to content

ChrisFlynn

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Posts posted by ChrisFlynn

  1. Out of curiosity, have you considered using the CSS sliding doors method of rollovers to avoid having to preload anything with JavaScript? If you create your images appropriately and just shift them with CSS when the mouse is over them, they are all preloaded already... Just a thought.

     

    This interests me - I'll have a google. Thanks for the suggestion! (Incidently, it's with regards to this page > http://keaneshaped.co.uk/disco - feel free to snoop at the code)

  2. I found this code to preload images - it works in IE6 and Opera, but not Firefox. Predictably, JSLint hates it.

     

     

    var myimages = new Array();
    function preloading() {
    for (x=0; x<preloading.arguments.length; x++) {
    	myimages[x] = new Image();
    	myimages[x].src = preloading.arguments[x];
    }
    }
    preloading("images/tn_thumb1over.jpg", "images/tn_thumb2over.jpg");
    preloading("images/tn_thumb2over.jpg", "images/tn_thumb4over.jpg", "images/tn_thumb5over.jpg");
    // etc for a total of about 30 rollover images
    

     

    I don't care about keeping this code (which I borrowed from the net anyway).

     

    Is there any magic code which anyone can recommend, which I should re-code my page to? Finding 'good' Javascript is pretty impossible, so it'd be great to know what is considered 'best practice'.

     

    Here's my criteria:

    * works for all 3 browsers (IE, FF, Opera - ideally all others too)

    * doesn't use array indexes by number (I add new images occasionally, and don't want to mess around with changing the array index)

    * is perhaps even is valid(!)

  3. Running http://validator.w3.org/checklink on http://keaneshaped.co.uk/faq (warning, it's 100kb of HTML with many links, so takes around 240 seconds on default).

     

    All my fragment links get the response:

     

    What to do: There are broken fragments which must be fixed.

     

    Response status code: 200

    Response message: OK

    Lines: 84, 85, 86, 87, 88, 89, 93, 94, 95, 99, 100, 101, 102, 103, 104, 108, 109, 110, 111, 115, 116, 117, 118, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 135, 136, 137, 138, 142, 143, 144, 148, 149, 150, 159, 161, 755

    Broken fragments and their line numbers: They need to be fixed!

     

    These fragment links works fine on IE6, FF2 and Opera 9, and validate with XHTML 1.0 Transitional. So, any idea why it's not link-validating? I'm a stickler for 'getting it right' and it's just going to annoy me otherwise :D

     

    Here is an example:

     

    <a href="#members">Who are Keane?</a >

     

    ...

     

    <h2><a name="members" id="members">Who are Keane?</a ></h2>

    (space added in </a > so it displays correctly on the forum)

     

     

    What's wrong with that? Any clues would be greatfully accepted!

  4. Hi everyone,

    Slightly off-topic, but I know this is a great forum :)

     

    I've just recently started a podcast, and am trying to get some useful stats on the mp3 downloads (don't care about xml views, so feedburner is not use to me ;)).

     

     

    On my hosting package I have got three stats applications. However:

     

    Webalizer hits

    episode 1 - 914

    episode 2 - 451

     

    Analog requests

    episode 1 - 914

    episode 2 - 451

     

    *AwStats views*

    episode 1- 696

    episode 2- 239

     

     

    My questions:

     

    1) Why the difference between AwStats and the others? Is AwStats filtering out duplicate users or something?

     

    2) What's the best way for me to count file downloads? (So I can see how many people are hearing my podcast). Ideally, I want to see the number of completed *.mp3 downloads for each file by day. I have access to my raw logs so what are the best simple apps? (Windows desktop or PHP)

    I don't care about referrers, times, agents etc... something like this would be great:

    20080424: Ep1.mp3 = 40, Ep2.mp3 = 23

    20080425: Ep1.mp3 = 23, Ep2.mp3 = 50

    ...

     

     

    2a) I only want to count complete downloads. If I get:

    70.107.132.22 - - [17/Apr/2008:03:23:19 +0100] "GET /Ep1.mp3 HTTP/1.1" 200 44628 "-" "iTunes/7.6.2 (Windows; N)"

    but I know my file is actually 3143523 bytes, I want to discount anything else (such as 44628). Is this possible using any apps, or even worthwhile? How does a resume work - is that 2 log entries, or just one?

     

     

     

    Any recommendations? :) I know it's not an exact science, but it'd be good to get close...

  5. A suggestion:

     

    You should program for firfox (or safari or opera) first, as they are standards compliants browsers, then adjust for IE afterwards, as it is not standards compliant. This will make your life a lot easier in the long run!

     

    I definitely agree. It also makes you more open - I was an avid IE fan (mainly because I think FF sucks), but Opera is pretty damn good...

     

     

    But back to the topic - where are the standards clearly defined? It seems a strange problem given that I've expressed it in CSS as I'd explain it in natural language, yet only IE can see it. So how do I work to the standard?

  6. I have a different (but related) issue now...

     

     

    I've got a 'middlepane' div. Within that is 'maincontainer' - which houses the content.

    I want 'advert' within the middlepane, on the far right.

    I also want the 'maincontainer' to be center of 'middlepane' (but text left aligned), but 'maincontainer' should never overlap with 'advert'.

     

     

     

    <html>
    <head>
    <style type="text/css">
    div.middlepane {
    width: 100%; margin-left: auto; margin-right: auto;
    text-align: center;
    }
    
    div.maincontainer {
    padding: 5px;
    width: 75%; margin-left: auto; margin-right: auto;
    background: #EEEEEE;
    border: 1px solid black;
    }
    
    div.advert {
    float: right;
    width: 160px;
    }
    </style>
    </head>
    <body>
    <div class="middlepane">
    <div class="advert">
    	<img src="images/mockad.gif" width="160" height="600" alt="advert" />
    </div>
    <div class="maincontainer">
    	<p>This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content.</p>
    	<p>This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content.</p>
    	<p>This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content.</p>
    	<p>This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content.</p>
    	<p>This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content.</p>
    	<p>This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content. This is some content.</p>
    </div>
    <div style="clear:both"></div>
    </div>
    </body>
    </html>

     

    IE understand what I mean.

    Firefox and Opera don't display what I mean.

  7. Dual core machines have 2 cores in one chip. So is the quoted speed (e.g. "1.8Ghz dual core") per core or per chip? Am I getting two flows of execution at 1.8Ghz each, or is effectively two 0.9Ghz cores amounting to a theoretical addition?

     

     

    I currently have a 3.5 year old 2.6Ghz Celeron machine, so am pretty surprised to see that new machines now don't have speeds a lot of Ghz faster (RIP Moore's Law). What's a very approximate equivalent in dual-core terms of my 2.6Ghz Celeron, and does anyone have any recommendations? Is quad significantly better than dual? Are certain models better? Or is it all about the RAM these days?

     

    The way I work is usually to have lots of things going on (I'm currently doing WAMP, ripping a CD, uploading, checking my email, have 5 browsers open - that's just light usage), and am not interested in gaming or graphics, if that helps...

  8. <html>
    <head>
    <style type="text/css">
    div.superbox {
    border: 1px solid #000000;
    width: 80%; margin-left: auto; margin-right: auto;
    }
    
    div.subbox1 {
    float: left;
    }
    div.subbox2 {
    float: right;
    width: 30%
    }
    </style>
    </head>
    <body>
    <div class="superbox">
    <div class="subbox1">
    	Content1
    </div>
    <div class="subbox2">
    	Content2
    	<div>Another another</div>
    	<div>And another</div>
    </div>
    </div>
    </body>
    </html>

     

    Within IE the content all displays within the superbox. On Firefox, it seems to 'fall out'. Any reason/workaround?

  9. A few more things...

     

    -you should be using ref_date.Date in your select column list, i.e. from the non-left joined table, for the reasons mentioned above.

     

    If I change my 'Date' column to select from ref_date, then the Sales column won't be counting transactions though? I definitely see the logic that I want every date from ref_date in my left join, but don't see how I can then achieve the sales count without a subquery...

     

     

     

    -you shouldn't use "date" as the column name, it's a reserved keyword, and it works by accident because you have prefixes

     

    Agreed - will update ASAP. Thanks for the tip.

     

    -you can use DATE() to just extract the date part of the datetime field; I think mysql might do this silent type converstion for you, but I prefer it to be explicit; date() reads more cleanly

     

    Agreed - much better than dateformat for this.

     

     

    I also didn't really understand what you wanted until right now.

     

    What you need is to  generate  a sequence of dates between the first date and today, and use this in your joins.  You can use an integers tables with date_add() from the initial date.

     

    Yes, I think I'm drifting a bit from my ultimate goal. I want to list the number of sales for each days between the first date there is a sale up to today (including days where there are no sales), ideally formatted DD/MM/YYYY. And I do like keeping it all to SQL if possible.

     

     

     

    Here's the latest:

    SELECT ref_date.Date AS 'Date', count( * ) AS 'Sales'
    FROM ref_date
    LEFT JOIN Transaction ON ( ref_date.Date = DATE(Transaction.Date) AND Transaction.productID= '1' )
    GROUP BY Transaction.Date

     

    2008-01-31 41 
    2008-02-12 1 
    2008-02-14 1 
    2008-02-14 1 
    2008-02-14 1 
    

  10. Thanks for your input.

     

    A few things:

     

    1) Don't use date_format in GROUP BY / ORDER BY clauses.  Morever, GROUP BY does an implicit ORDER BY.

     

    OK - great.

     

    2) Because your where clause includes a reference to the left-joined table, you've effectively made this an inner join again.  You need to add this condition to your on clause instead.

     

    I see. I've only done inner joins before which is why I'm struggling (I know it's basic!)

     

    3) Haven't followed the whole thread, but you should really use proper date column types for all of your dates, not varchars.

     

     

    To clarify:

     

    Transaction.Date is: datetime NOT NULL (e.g. 2008-02-14 22:41:28)

    ref_date.Date is: date NOT NULL (e.g. 2008-02-01)

     

    Hence the date_format madness, as I want to group by date, and throw away the H:M:S.

     

     

    Ideally I want it in DD/MM/YYYY format, but whatever I can get working at the moment is good enough(!)

     

     

     

     

     

     

    So:

     

    SELECT date_format( Transaction.Date, '%Y-%m-%d' ) AS 'Date', count( * ) AS 'Sales'
    FROM ref_date
    LEFT JOIN Transaction ON ( ref_date.Date = date_format( Transaction.Date, '%Y-%m-%d' )  AND Transaction.productID = '1' )
    GROUP BY Transaction.Date
    

     

    This outputs the following:

    NULL 41 
    2008-02-12 1 
    2008-02-14 1 
    2008-02-14 1 
    2008-02-14 1 
    

     

     

     

    Also, doing:

    SELECT Transaction.Date AS 'Date', count( * ) AS 'Sales'
    FROM ref_date
    LEFT JOIN Transaction ON ref_date.Date = Transaction.Date
    AND Transaction.productID = '1'
    GROUP BY Transaction.Date

     

    Gives:

    Date  Sales  
    NULL 43 

     

     

     

     

    I appreciate I haven't made it totally clear from the start, but I appreciate everyone's help! :)

  11. However, as it involves creating an array of dates anyway, I'd use option 2, like this

     

    <?php 
    $mindate = '2008-02-01';
    $t = strtotime($mindate);
    $dates = array();
    
    while ($t <= time())
    {
        $d = date('Y-m-d', $t);
        $dates[$d] = 0;
        $t = strtotime ('+1 days', $t);
    }
    
    /**
    * Now your original query putting the totals in to the array by date key
    */
    $sql = "select Date, count(*) as 'Sales'
            from Transaction
            where productID='5'
            group by Date
            order by Date";
    $res = mysql_query($sql);
    while (list($d, $v) = mysql_fetch_row($res))
    {
        $dates[$d] = $v;
    }
    
    foreach ($dates as $$d => $sales)
    {
        echo date('d/m/Y', strtotime($d)) . ' ' . $sales . '<br/>';
    }
    ?>

     

    I've also tried this, but get the somewhat cryptic:

     

    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 0
    01/01/1970 1
    01/01/1970 1
    01/01/1970 1
    01/01/1970 1

     

    I'm starting to wonder if it's something to do with the date format of my tables?

  12. Two approaches

     

    1 ) another table with a row for each date and use "FROM dates LEFT JOIN transaction

     

    I think I like the pure SQL approach best. I've now filled up the table; however I'm still only getting:

     

    Date  Sales  
    2008-02-12 1 
    2008-02-14 3 

     

     

    Transaction.Date is DATETIME, ref_date is DATE, so I've done a little bit of (ugly) formatting...

     

    SELECT date_format( Transaction.Date, '%Y-%m-%d' ) AS 'Date', count( * ) AS 'Sales'
    FROM ref_date
    LEFT JOIN Transaction ON ref_date.Date = date_format( Transaction.Date, '%Y-%m-%d' ) 
    WHERE Transaction.productID = '1'
    GROUP BY date_format( Transaction.Date, '%Y-%m-%d' ) 
    ORDER BY date_format( Transaction.Date, '%Y-%m-%d' ) 
    

  13. Two approaches

     

    1 ) another table with a row for each date and use "FROM dates LEFT JOIN transaction

     

    Thanks for the answer - this definitely makes sense!

     

    What's the best way to create this 'dates' reference table, and fill it up? I'd normally use Excel's Autocomplete, but I can't get it to format right... Is there a nice SQL way of filling things up? ['01/01/2007'..'31/12/2010']

     

    Chris

  14. How does your table look?

     

    Basically (I've cut the crap):

     

    CREATE TABLE `transaction` (
      `Email` varchar(255) NOT NULL,
      `Date` datetime NOT NULL,
      `TransactionID` varchar(255) NOT NULL,
      `ProductID` smallint(5) unsigned NOT NULL,
      PRIMARY KEY  (`TransactionID`)
    )

     

    Each row represents a successful transaction.

  15. MySQL - 5.0.45

     

    select date_format(Date, '%d/%m/%Y') as 'Date', count(*) as 'Sales'
    from Transaction
    where productID='5'
    group by date_format(Date, '%d/%m/%Y')
    order by date_format(Date, '%d/%m/%Y')
    

     

    Result:

     

    Date Sales 
    12/02/2008 1 
    14/02/2008 3 
    

     

     

    I want to have every day displayed; from the first one that exists (min Date) up to today. E.g.

     

    Date Sales 
    12/02/2008 1
    13/02/2008 0
    14/02/2008 3
    15/02/2008 0

     

     

    I'm guessing I need some kind of join, but I can't figure it out - what's the most elegant way of doing it?

  16. I guess this is an ordering issue, but no amount of changing the position of [L] seems to work...

     

    I'm trying to get the following behaviour on these two conditions:

     

     

    1)

    User visits: http://domain.com/foo

    They see that in their address bar.

    The page loaded is http://domain.com/page.php?value=foo

     

    (To be pedantic, spaces and underscores should be replaced with hyphens in the address bar too - is this possible with [R]? I can parse the value on page.php so that's not an issue...  Value should accept hyphens, numbers, letters etc)

     

     

    2)

    I also have some 'real' pages which do actually exist (e.g. faq.php, index.php).

     

    User visits: http://domain.com/faq  (no extension)

    They see that in their address bar.

    The page loaded is http://domain.com/faq.php

     

     

    I'm currently achieving the latter with: RewriteRule ^([a-z]+)$ /$1.php, but this isn't working alongside the first RewriteRule ^([A-Za-z0-9-]+)/$ page.php?value=$1 [L]

     

     

    Is there a dynamic way of getting both working, without hard-coding all my 'real' pages in?

  17. My profound apologies if this has been covered recently - if someone can post a link or even just some good search words that would be brilliant.

     

     

    OK, I have folders full of MP3s. I've adapted a script to dynamically these folders, and serve them to users - this works. However, now my hosting have now cut me off as their tmp files are getting full and they have to clean them.

    I'm guessing what is happening is people are pressing 'cancel' during the download and my script is being terminated since the interaction with the user is termitated? I added a try/catch but this didn't work (I'm more familiar with Java, so don't know if it works in the same context).

     

    Could anyone see any solutions? (I have limited disc space, so need to create ZIPs 'on the fly').

     

     

    <?PHP
    $filename_no_ext=$_GET['download'];
    if (!is_dir($filename_no_ext)) { echo 'Folder not found'; die(); }
    
    
    header("Content-Type: archive/zip");
    header("Content-Disposition: attachment; filename=$filename_no_ext".".zip");
    $tmp_zip = tempnam ("tmp", "tempname") . ".zip";
    `zip -r $tmp_zip $filename_no_ext`;
    $filesize = filesize($tmp_zip); header("Content-Length: $filesize");
    try {
    $fp = fopen("$tmp_zip","r");
    echo fpassthru($fp);
    } catch (Exception $e) {
    `rm $tmp_zip `;
    }
    
    // clean up the tmp zip file
    `rm $tmp_zip `;
    ?>
    

     

    Any obvious solutions of how to fix 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.