Jump to content

nogray

Members
  • Posts

    930
  • Joined

  • Last visited

Posts posted by nogray

  1. Just add the this.value to the url like this

    [code]
    <SELECT "cars" onchange="window.location='cars.php?sort='+this.value">
    <OPTION value="ford">ford</OPTION>
    <OPTION value="toyota">toyota</OPTION>
    </SELECT>
    [/code]
  2. I notice the solutions where a bit too complicated for this problem

    time() function in php will return the number of seconds, so if you have two times and subtract them, you'll get the difference in seconds. All you have to do is convert that into minutes, hours, days, etc...

    I wrote a small function that will do that

    [code]function convert_time($seconds){
        $f_minutes = $seconds / 60;
        $i_minutes = floor($f_minutes);
        $r_seconds = intval(($f_minutes - $i_minutes) * 60);
        
        $f_hours = $i_minutes / 60;
        $i_hours = floor($f_hours);
        $r_minutes = intval(($f_hours  - $i_hours) * 60);
        
        $f_days = $i_hours / 24;
        $i_days = floor($f_days);
        $r_hours = intval(($f_days - $i_days) * 24);
        
        if ($i_days > 0) $r = "$i_days days ";
        if ($r_hours > 0) $r .= "$r_hours hours ";
        if ($r_minutes > 0) $r .= "$r_minutes min";
        else $r = "less than a minute";
        
        return $r;
    }[/code]

    the f_ is for float i_ is for int and r_ is the return value. I only need days, so you can keep going for months and years the same way.

    Good luck,

    Wesam Saif
    [a href=\"http://www.nogray.com\" target=\"_blank\"]http://www.nogray.com[/a]
×
×
  • 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.