Krone Posted May 23, 2014 Share Posted May 23, 2014 Hi, I'm looking to create a webpage that will display a bottling schedule from our database in a calendar format for easy viewing. That part I get and should be easy to do. Use some PHP run a query pull it up. But then what I would like to do is be able to rearrange the bottling schedule by dragging objects from one date to another. So for example, if on May 16th there was a Merlot bottling for 1000 cases, I could drag that to May 20th, and then it would change the database. Again, I understand how to do that once the drag event has been triggered, but I'm not quite sure how to trigger the drag event. I'm thinking it will have to be Javascript for Jquery, but I'm not quite sure how it would work. Any ideas? Thanks, Link to comment Share on other sites More sharing options...
justsomeguy Posted May 23, 2014 Share Posted May 23, 2014 Anything interactive in the browser is Javascript. PHP runs on the server, not the browser. If they are interacting with an existing page without the page refreshing, all of that is Javascript. You can send ajax requests to the server to update the database without the page refreshing. Link to comment Share on other sites More sharing options...
Krone Posted May 23, 2014 Author Share Posted May 23, 2014 Cool, so this seems like it might do what I want http://jqueryui.com/droppable/ Then I would just need to trigger an AJAX event that would go back to the PHP. Link to comment Share on other sites More sharing options...
MrFish Posted May 24, 2014 Share Posted May 24, 2014 Cool, so this seems like it might do what I want http://jqueryui.com/droppable/ Then I would just need to trigger an AJAX event that would go back to the PHP. That would do it. Good luck. Link to comment Share on other sites More sharing options...
Krone Posted May 25, 2014 Author Share Posted May 25, 2014 Ok, so I've made some pretty good progress, but for some reason, my table headers don't always line up. http://thereal805productions.com/calendar/calendar.php while ( $day_num <= $days_in_month ) { $matched = false; ?> <td> <!-- this should be a table inside each date --> <table> <th> <div id = "<?php echo $myDate ?>" class = "droppable ui-widget-header" > <?php echo $day_num ?> </div> </th> <?php $result = $conn->query($sql); foreach ($result as $row) { // echo "row = " . $row['date'] . " and myDate = " . $myDate; if ($row['botdate'] == $myDate) { ?> <tr><td><div id = '<?php echo $row['id'] ?>' class="draggable ui-widget-content "> <?php echo $row['productId']; ?> </div></td></tr> <?php $matched = true; } else if ($matched == false) { ?> <tr><td> </td></tr> <?php } } ?> <!-- ends the foreach --> </table> </td> <!-- ends the table inside each date --> <?php $day_num++; $day_count++; $myDate = strtotime("+1 day", strtotime($myDate)); $myDate = date("Y-m-d", $myDate); //Make sure we start a new row every week if ($day_count > 7) { echo "</tr><tr>"; $day_count = 1; } } // ends the while loop Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now