Jump to content

sleepyw

Members
  • Posts

    81
  • Joined

  • Last visited

Everything posted by sleepyw

  1. Now that I look at that, I'm still clueless. Why does it start with SELECT? What goes in front of that? There are elements missing and I don't know what they are. If you look at my sample code in the OP, I just need to re-write that. I'm too new to PHP where code snippets don't help because I don't know how to fill in the blanks yet. To do DateDiff(), I need an entire function written, i think. Using simple math functions don't seem to be working on DATE fields (yyyy-mm-dd).
  2. Thanks for taking the time to write that up - I'll have to play with it over the weekend and see if I can get it to work.
  3. I'm not sure I follow. What's the output of that - total days? Or total days minus weekends? And I would use my database fields of start_date and end_date in place of the dates you listed, I assume. I'm not sure what I'd do with this when I was done, based on the sample code I posted that I'm trying to produce.
  4. Unfortunately, that doesn't help me. I could do the database with the holidays, but the formula for calculating the duration between dates is where I'm lost. Everything online I've found is riddled with errors and datediff() doesn't seem to work just to calculate even total days.
  5. I'm very new to PHP and have been using tutorials and help from across the net to create my site. But I can't find a working code to do what I need. I have a table with a start date and end date and I want to calculate the duration between those dates in WORKING days (and exclude public holidays, if possible). I have an HTML form where the user inputs the start date and end date, then I want the php file handling the update to parse the duration field automatically. Here's what I have, which is of course wrong, but maybe it will help explain what I'm trying to do: //$_GET['all the variables from the HTML form']; $id = $_POST['id']; $bus_name = $_POST['bus_name']; $web_url = $_POST['web_url']; $image_name = $_POST['image_name']; $start_date = $_POST['start_date']; $end_date = $_POST['end_date']; $duration = datediff($_POST['end_date'], $_POST['start_date']); //but this needs to only include weekdays (non-public holiday weekdays if possible) // update data in mysql database $sql="UPDATE table_name SET id='$id', bus_name='$bus_name', web_url='$web_url', image_name='$image_name', start_date='$start_date', end_date='$end_date', duration='$duration' WHERE id='$id'"; $result=mysql_query($sql); I can't seem to find anything that works that takes data from a form and calculates it to write to the db. Any help would be very much appreciated.
×
×
  • 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.