Jump to content

peipst9lker

Members
  • Posts

    81
  • Joined

  • Last visited

    Never

Posts posted by peipst9lker

  1. You can use mktime() and date() to get the last monday and then convert it into datetime format.

     

    Here's a little snippet for datetime conversion, the rest is for you because I don't have much time right now.

     

    function strToDateTime($input)
    {
    return preg_replace('/^(\d{2}).(\d{2}).(\d{4}) (\d{2})\d{2})\d{2})$/', '$3-$2-$1 $4:$5:$6', $input);
    }

     

    Edit: Forgot to mention, you can use > and < operators in datetime where-clauses.

  2. Replace $fruits with your array.

     

    $totals = array();
    foreach ($fruits as $fruit)
    foreach ($fruit as $type => $val) {
    	if (isset($totals[$type]))
    		$totals[$type] += (int)$val;
    	else
    		$totals[$type] = (int)$val;
    }
    

  3. $row['DS'] // type :float (with one decimal like 12.2)

    $row['TC'] // type :float (with one decimal like 24.2)

    what im exctaly try to do in the make the above calcualtion

    $row['TC'] / $row['DS'] ( $row['DS'] need to be as intenger (without point,like 12)

    and the resulte should be with two decimal like (2.32)

     

    Use typecasting

     

    $var = ($row['TC'] / (int)$row['DS']);

     

    For the future please put code in

     tags! (remove the spaces in the brackets)
  4. Table resources: id, name, amount

    Table bookings: id, resource_id, amount_booked, booking_date, etc.

     

    Example:

    You have a resource with id 1, name is Camera XY, amount is 30.

    Someone already created a booking of resource_id = 1 and amount_booked = 10.

    Execute a query which sums up amount_booked from table bookings where resource_id = 1 and you're done

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