Jump to content

mongoose0031800

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by mongoose0031800

  1. Hey All, I'm trying to make several date fields (dynamically populated) that all will have the jQuery datepicker on them. Then I want to use AJAX to get the value of a field after the user selects the date. Here is my code so far. <script type="text/javascript"> $(function(){ $("#date").datepicker({ onSelect: function(dateText, inst) { var date = dateText; $("#info").load("server.php?date="+date); } }); }); </script> </head> <body> <div id="info"></div> <input id="date"> I can get the date that the user picked for the field #date in the AJAX now. But if I add more date fields...date_1, date_2, date_3...I don't know how to tell jquery to use datepicker on those fields. When the date fields get dynamically populated the format would be "date_#DB_id". I also need a way to reference that id so I can update the item in the database. Did I explain this well enough?
  2. Also, this post should be in the "PHP Coding Help" sub-forum not the AJAX Help forum. I imagine it will be moved soon, just thought I'd mention it to you for future reference. Mongose
  3. I don't understand exactly what you are trying to do. Can you try to explain what you are attempting to accomplish with the above script more clearly and in more detail? Then I should be able to help you. Mongoose
  4. Ok problem solved. But here's the code that fixed it in case anyone else has the same issue. $(document).ready(function() { $("#show_list").sortable({ handle : '.handle', update : function () { var order = $('#show_list').sortable('serialize'); $("#info").load("scripts/process_show_order.php?"+order,function(){ location.reload(); }); } }); });
  5. Hello, I'm trying to add a line to my jQuery function that would make the page refresh after the AJAX was finished. This is my original script below that works fine. $(document).ready(function() { $("#show_list").sortable({ handle : '.handle', update : function () { var order = $('#show_list').sortable('serialize'); $("#info").load("scripts/process_show_order.php?"+order); } }); }); And this is my modified script that doesn't work. $(document).ready(function() { $("#show_list").sortable({ handle : '.handle', update : function () { var order = $('#show_list').sortable('serialize'); $("#info").load("scripts/process_show_order.php?"+order); }, location.reload(); }); }); I added the , after the function ended } and then on the next line I added location.reload();...which broke the script. Am I doing something wrong? Mongoose
  6. No luck still. This has to be a cache issue..
  7. I just had someone else tell me it works fine for him in FF 3.6...sounds like a cache issue. But I disabled cache and I still don't have it working in FF so I'm going try downgrading from FF 5.0 to FF 3.6 and see what happens although that shouldn't matter since it works in FF 5.0 locally. This is really strange..
  8. I'm sorry, I should have been more specific..I've just been pulling so much hair out of my head that I wasn't thinking. Here is a link - http://sharpenedconception.com/development/jumpin_jupiter/admin_show_order.php Login is disabled for development purposes. The drag and drop doesn't function when it is live. If it's local it does. It acts like the required files are not on the server or the code isn't coded properly but I've checked all of this and everything checks out fine. Also, maybe this will help, a while back I ran into a problem that really sticks out in my mind and I think was along the same lines of what is going on here. I had some javascript or jQuery that wasn't working. It was the same issue, it worked on my local machine but not when I put it live no matter where it was. Finally, after much hair pulling, I did something simple but I can't remember what it was. I think I changed some " or ' to the opposite ' or " in the <script> tags or did something else to the <script> tags. I don't know...I can't remember and I've been searching through old code to try and get a hint as to what it was but I've had no luck either. Maybe this will help. The link below seems like he had the same problem I had a while back and fixed it the same way but I don't fully understand what he did to fix it. http://stackoverflow.com/questions/3065904/jquery-draggable-not-working-in-chrome-safari Please let me know if any of this helps at all. **EDIT Now in the jQuery forum someone else said that the drag and drop at the link I provided works fine for him in Chrome. Can someone else test this in Chrome or any other browser besides IE? I just tested it again in Chrome (cleared cache), FF, Safari and it still doesn't work for me.
  9. Firebug did give me errors. The errors keep referring to this line. $(document).ready(function() { Any idea? Or is there anything I can provide to help narrow this down?
  10. Yes I've checked firebug and it appears it is throwing no errors. Like I said, it works in FF as long as it is local on my computer...only when I put it live does it quit working. All the required files are on the server and are accessible. Nothing makes any sense. I've also made a post in the jQuery forum but haven't gotten any response. Mongoose
  11. That is one of the first things I did. That's a pretty normal step in the beginning of my debugging process and should be of any experienced developer in my opinion, but thanks for the help! Mongoose
  12. I get no error at all. The only symptom is that in IE I can drag and drop the items, FF, Chrome, Safari I cannot. But if I'm my local on my computer the drag and drop works in all browsers.
  13. Hey All, The following code works on all browsers when I'm testing locally on my computer. When I put it live though on my server, it works in IE, but not FF, Chrome, or Safari. I'm not sure what the issue is. The code uses Jquerys sortable function and AJAX with PHP to make a drag and drop script which allows the user to organize the items easily. Like I said, I'm not sure what the issue is...can anyone help? Is it my PHP, my Jquery at the top, something else? I know it's probably something small and stupid. Also, I know there is a possibility this might not be a PHP problem but I don't know if thats the case for sure and I put it in this thread because no one looks at the JS or other threads too often and it just might be a PHP issue. Please don't move the thread for my sake so there is a chance I might get some help. Thanks so much! PHPFreaks rocks! Mongoose <?php //disable magic quotes require_once('includes/disable_magic_quotes.inc.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Change Show Order</title> <link rel="stylesheet" type="text/css" href="styles/view.css" media="all"> <link rel="stylesheet" type="text/css" href="styles/ui-lightness/jquery-ui-1.8.15.custom.css" media="all"> <script type="text/javascript" src="javascript/view.js"></script> <script type="text/javascript" src="javascript/calendar.js"></script> <script type="text/javascript" src="javascript/jquery-1.6.2.min.js"></script> <script type="text/javascript" src="javascript/jquery-ui-1.8.15.custom.min.js"></script> <style> ul#show_list { list-style:none; margin:0; padding:0; } ul#show_list li { float:left; width:153px; padding:1px; margin: 3px 3px 3px 0; } .ui-state-highlight { height: 206px; } #info { display: block; padding: 10px; margin: 0px; border: 1px solid #333; background-color: #efefef; } /* li.show_listing_container { float:left; margin:5px 0px 10px 0px; font-family:Arial, Helvetica, sans-serif; width:169px; padding:0; } li.show_listing_container a{ width:169px; } */ </style> <script type="text/javascript"> $(document).ready(function() { $("#show_list").sortable({ handle : ".handle", update : function () { var order = $("#show_list").sortable("serialize"); $("#info").load("scripts/process_show_order.php?"+order); } }); }); </script> </head> <body id="main_body" > <img id="top" src="images/top.png" alt=""> <div id="form_container" style="width:716px"> <h1><a>Add Show</a></h1> <form id="form_200831" class="appnitro" enctype="multipart/form-data" method="post" action=""> <div class="form_description"> <h2>Change Show Order</h2> <p>Use the form below to drag and drop the shows into the order you would like them to be displayed in.</p> <?php require_once('includes/admin_nav.inc.php'); ?> </div> <pre style="margin:0; padding:0;"> <div id="info">Drag shows to update show order.</div> </pre> <ul id="show_list"> <?php require_once('scripts/dbconfig.php'); $get_shows = mysql_query("SELECT * FROM shows WHERE front_page_featured = '1' ORDER BY position ASC"); while($row = mysql_fetch_array($get_shows)) { ?> <li id="listItem_<?php echo $row['id']; ?>"> <div class="show_listing_image"><img src="images/show_images/small/<?php echo $row['picture_1']; ?>" border="0" width="153px" class="handle"></div> <div class="show_listing_title"><?php echo $row['title']; ?></div> <div class="show_listing_date"><?php echo date("l, F jS", strtotime($row['date'])); ?></div> </li> <?php } ?> </ul> </form> <div id="footer"> </div> </div> <img id="bottom" src="images/bottom.png" alt=""> </body> </html>
  14. Thanks its working now!
  15. Hey all, Why isn't my script outputting any value when I use the following code? $item_count = count($_POST['qty']); die($item_count-1); I've already tested that $_POST['qty'] isn't empty. If I output count($_POST['qty']) then it displays a value. But if I try to subtract a value of 1, no value comes out. I swear I've seen people add/subtract values from a count function...am I wrong about this? Thanks! mongoose
  16. Great! That worked! Thanks so much!
  17. One thing that may complicate this a little is I am already ordering the query by a field called position which is an integer. Here is my query: $get_shows = mysql_query("SELECT * FROM shows WHERE front_page_featured = '1' ORDER BY position ASC");
  18. Hello again! How would I go about displaying data from a database query but only showing the results that have a date (in the date field in the db) the is either equal to the current date or in the future? Not show any results in which the date field has a date which is in the past? Thanks! Mongoose
  19. Alright guys, here is my final working version..tell me what you think. <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>PHP Calendar</title> <!--[if IE]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <style type="text/css"> div.day-number { background:#999; position:absolute; z-index:2; top:-5px; right:-25px; padding:5px; color:#fff; font-weight:bold; font-size:12px; width:20px; text-align:center; } td.calendar-day, td.calendar-day-np { width:120px; padding:5px 25px 5px 5px; border-bottom:1px solid #999; border-right:1px solid #999; font-size:12px; } table.calendar td { } </style> </head> <body> <?php /* draws a calendar */ function draw_calendar($month,$year,$events = array()){ /* draw table */ $calendar = '<table cellpadding="0" cellspacing="0" class="calendar" width="634px">'; /* table headings */ $headings = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); $calendar.= '<tr class="calendar-row"><td class="calendar-day-head">'.implode('</td><td class="calendar-day-head">',$headings).'</td></tr>'; /* days and weeks vars now ... */ $running_day = date('w',mktime(0,0,0,$month,1,$year)); $days_in_month = date('t',mktime(0,0,0,$month,1,$year)); $days_in_this_week = 1; $day_counter = 0; $dates_array = array(); /* row for week one */ $calendar.= '<tr class="calendar-row">'; /* print "blank" days until the first of the current week */ for($x = 0; $x < $running_day; $x++): $calendar.= '<td class="calendar-day-np"> </td>'; $days_in_this_week++; endfor; /* keep going with days.... */ for($list_day = 1; $list_day <= $days_in_month; $list_day++): $calendar.= '<td class="calendar-day"><div style="position:relative;height:100px;">'; /* add in the day number */ $calendar.= '<div class="day-number">'.$list_day.'</div>'; if($list_day <= 9) { $event_day = $year.'-'.$month.'-0'.$list_day; } else { $event_day = $year.'-'.$month.'-'.$list_day; } if(isset($events[$event_day])) { foreach($events[$event_day] as $event) { $calendar.= '<div class="event">'.$event['title'].'</div>'; } } else { $calendar.= str_repeat('<p> </p>',2); } $calendar.= '</div></td>'; if($running_day == 6): $calendar.= '</tr>'; if(($day_counter+1) != $days_in_month): $calendar.= '<tr class="calendar-row">'; endif; $running_day = -1; $days_in_this_week = 0; endif; $days_in_this_week++; $running_day++; $day_counter++; endfor; /* finish the rest of the days in the week */ if($days_in_this_week < : for($x = 1; $x <= (8 - $days_in_this_week); $x++): $calendar.= '<td class="calendar-day-np"> </td>'; endfor; endif; /* final row */ $calendar.= '</tr>'; /* end the table */ $calendar.= '</table>'; /** DEBUG **/ $calendar = str_replace('</td>','</td>'."\n",$calendar); $calendar = str_replace('</tr>','</tr>'."\n",$calendar); /* all done, return result */ return $calendar; } function random_number() { srand(time()); return (rand() % 7); } /* date settings */ $month = ($_GET['month'] ? $_GET['month'] : date('m')); $year = ($_GET['year'] ? $_GET['year'] : date('Y')); /* select month control */ $select_month_control = '<select name="month" id="month">'; for($x = 1; $x <= 12; $x++) { if($x <= 9) $x = '0'.$x; $select_month_control.= '<option value="'.$x.'"'.($x != $month ? '' : ' selected="selected"').'>'.date('F',mktime(0,0,0,$x,1,$year)).'</option>'; } $select_month_control.= '</select>'; /* select year control */ $year_range = 7; $select_year_control = '<select name="year" id="year">'; for($x = ($year-floor($year_range/2)); $x <= ($year+floor($year_range/2)); $x++) { $select_year_control.= '<option value="'.$x.'"'.($x != $year ? '' : ' selected="selected"').'>'.$x.'</option>'; } $select_year_control.= '</select>'; /* "next month" control */ $next_month_link = '<a href="?month='.($month != 12 ? $month + 1 : 1).'&year='.($month != 12 ? $year : $year + 1).'" class="control">Next Month >></a>'; /* "previous month" control */ $previous_month_link = '<a href="?month='.($month != 1 ? $month - 1 : 12).'&year='.($month != 1 ? $year : $year - 1).'" class="control"><< Previous Month</a>'; /* bringing the controls together */ //$controls = '<form method="get">'.$select_month_control.$select_year_control.' <input type="submit" name="submit" value="Go" /> '.$previous_month_link.' '.$next_month_link.' </form>'; $controls = '<form method="get">'.$select_month_control.$select_year_control.' <input type="submit" name="submit" value="Go" /> </form>'; require_once('scripts/dbconfig.php'); /* get all events for the given month */ $events = array(); $query = "SELECT *, DATE_FORMAT(date,'%Y-%m-%d') AS event_date FROM shows WHERE DATE_FORMAT(date,'%Y-%m') LIKE '".$year."-".$month."'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { $events[$row['event_date']][] = $row; } echo '<h2 style="float:left; padding-right:30px;">'.date('F',mktime(0,0,0,$month,1,$year)).' '.$year.'</h2>'; echo '<div style="float:left;">'.$controls.'</div>'; echo '<div style="clear:both;"></div>'; echo draw_calendar($month,$year,$events); echo '<br /><br />'; /* echo $query; echo '<pre>'; print_r($events); echo '</pre>'; */ ?> </body> </html>
  20. OK, also I have another version but it is completely different from the one above if you would like to see it.
  21. Is there anything else I need to provide to help?
  22. This is my code so far.. <section id="content" class="planner"> <h2> <?php $date_db = strtotime("07/01/2011"); echo date("F Y", $date_db) ?> </h2> <table class="month"> <tr class="days"> <td>Mon</td> <td>Tues</td> <td>Wed</td> <td>Thurs</td> <td>Fri</td> <td>Sat</td> <td>Sun</td> </tr> <?php $today = date("d", $date_db); // Current day $month = date("m", $date_db); // Current month $year = date("Y", $date_db); // Current year //die($today); /* $today = date("d"); // Current day $month = date("m"); // Current month $year = date("Y"); // Current year */ $days = cal_days_in_month(CAL_GREGORIAN,$month,$year); // Days in current month $lastmonth = date("t", mktime(0,0,0,$month-1,1,$year)); // Days in previous month $start = date("N", mktime(0,0,0,$month,1,$year)); // Starting day of current month $finish = date("N", mktime(0,0,0,$month,$days,$year)); // Finishing day of current month $laststart = $start - 1; // Days of previous month in calander $counter = 1; $nextMonthCounter = 1; //if the start day is greater than a Friday; if it is, we have 6 rows, otherwise we have 5 if($start > 5){ $rows = 6; }else {$rows = 5; } //we then have a nested loop - one for the weeks, and one for the days in the weeks for($i = 1; $i <= $rows; $i++){ echo '<tr class="week">'; for($x = 1; $x <= 7; $x++){ if(($counter - $start) < 0){ $date = (($lastmonth - $laststart) + $counter); $class = 'class="blur"'; echo '<td '.$class.'><a class="date"></a></td>'; }else if(($counter - $start) >= $days){ $date = ($nextMonthCounter); $nextMonthCounter++; $class = 'class="blur"'; echo '<td '.$class.'><a class="date"></a></td>'; }else { $date = ($counter - $start + 1); if($today == $counter - $start + 1){ $class = 'class="today"'; } echo '<td '.$class.'><a class="date">'. $date . '</a></td>'; } $counter++; $class = ''; } echo '</tr>'; } ?> </table> </section> I've got it outputting one month so far but not organizing the items into it and not showing 5 months instead of one. Most of that code is from a tutorial. What I want to do is output 5 months (current and 4 in the future) and loop through items in my database and have PHP sort the items into the calendar. Any advice on where I go from here? PHPFREAKS ROCKS!
×
×
  • 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.