Jump to content

byroncoolie

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

About byroncoolie

  • Birthday 08/28/1970

Contact Methods

  • Website URL
    http://www.dinosaurus.com.au/f1/f1.html

Profile Information

  • Gender
    Not Telling
  • Location
    Melbourne, Australia

byroncoolie's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Friends, I have a PHP script that populates a calendar based on an array as follows: $days = array(2=>array('javascript:showWhatsOnText(2);','linked-day'), 3=>array('javascript:showWhatsOnText(3);','linked-day'), 4=>array('javascript:showWhatsOnText(4);','linked-day')); echo generate_calendar(2011, 4, $days, 1, '#'); where, for instance, the 2, 3 4 are the days of the month, By extracting a series values from a MySQL database how would I generate this array dynamically. E.g I have startday, startmonth, name and text fields in the database and would need to loop through them all to create the array. I tried playing around with something like this without any luck: $queryCat1 = "SELECT * FROM $dbCalendarEvents ORDER BY id ASC"; // WHERE visible = '1' $result1 = mysql_query($queryCat1) or die (mysql_error()); $num1 = mysql_num_rows($result1); $i=0; $daysArray = array(); while ($i < $num1) { $startday=mysql_result($result1,$i,"startday"); $startmonth=mysql_result($result1,$i,"startmonth"); $name=mysql_result($result1,$i,"name"); $name=mysql_result($result1,$i,"name"); $copy=mysql_result($result1,$i,"copy"); $daysArray[$i] = $startday=>array('/weblog/archive/2004/Jan/02','linked-day'); $i++; } Your help is appreciated.
  2. Thank you, I did consider the length of the URL but the (obscure) error message swayed me from this. I investigated it further by changing the GET to a POST and have resolved the issue. Thanks. Here's the final code: THE SORT PAGE: <script type="text/javascript"> $(document).ready(function() { $("#list").sortable({ // list is the id of the UL handle : '.handle', update : function () { var order = $('#list').sortable('serialize'); // produces string of listItem[]=1&listItem[]=3&listItem[]=2 where listItem is the id of the LI's in the UL $.post('product_sortable-process.php', order); } }); }); </script> THE ACTION PAGE: foreach ($_POST['listItem'] as $position => $item){ $sql = "UPDATE $dbProd SET `position` = '$position' WHERE `id` = '$item'"; mysql_query($sql) or die(mysql_error()); } All thanks to this post by Bart: http://stackoverflow.com/questions/654535/jquery-what-to-do-with-the-list-that-sortableserialize-returns
  3. It's part of a CMS. The page that displays all products has the facility to re-order them by dragging and dropping, hence the basic ajax functionality. By dragging and dropping this creates a querystring of all the new order ids and product ids which is then processed by a script to do the database work. The querystring looks like this: ?listItem[]=1&listItem[]=3&listItem[]=2 etc etc. When this exceeds 280 items it fails in the script that splits the array and does the database update. The database cannot handle more than 280 requests in the loop. Here is the actual script (we have used this in our build): http://www.wil-linssen.com/musings/entry/extending-the-jquery-sortable-with-ajax-mysql/ Hope this helps.
  4. Thanks in advance all. I have an AJAX list sorting script that loops through an array and changes the 'position' field in a db table. This works great until the number of records in the array exceeds 280. I'm trying to work out how to overcome this. A time delay usleep() does not help. Perhaps I need to count the records and split the operation of the function into blocks of 280. Perhaps I need to open a database connection then close it and open it again after 280 records. Here is the script: foreach ($_GET['listItem'] as $position => $item){ $sql = "UPDATE $dbProd SET `position` = '$position' WHERE `id` = '$item'"; mysql_query($sql) or die(mysql_error()); $query .= $sql; } print_r ($query);
×
×
  • 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.