Jump to content

Scriptaculous acting weird... might be mysql?


Recommended Posts

Hello! First Post! Yay!

 

I have a web application in which I use scriptaculous' sortable and mysql.  The sortable posts its order to my mysql database thanks to a "ranking" field, and it works fine.  There is another list on the page that reads the ranking from the sortable and displays the list again, but this time non-sortable. On update of the sortable, and after posting the data to the mysql database, the list refreshes thanks to an AJAX div refresh.

 

There lies the problem.  When the div refreshes, sometimes it refreshes with the list displayed in the correct order, sometimes it displays in an incorrect order. Sometimes it seems like it may be lagging 1-2 updates behind.  I know that it isn't the post of the sortable data, because I check the data in phpMyAdmin after an update and it is always correct.  Also, it isn't the code which displays the list I don't think, because when I refresh the browser, that same code displays the list correctly.

 

Is there just something that I'm missing here?

 

Here's the code that reads the data for the list, and displays it:

 

require('database2.php');
    function getMovies2()
    {
        $query = 'select movie_id, title from movies order by ranking, lower(title)';
        $result = mysql_query($query) or die(mysql_error());

        $movies = array();
        while ($row = mysql_fetch_object($result)) {
            $movies[$row->movie_id] = $row->title;
        }

        return $movies;
    }


    $movies = getMovies2();
?>
<ul id="movies_list">
            <?php foreach ($movies as $movie_id => $title) { ?>
               <li id="movie_<?= $movie_id ?>"><h3><?= $title ?></h3>
                
                </li>
            <?php } ?>
        </ul>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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