I have a simple SELECT query that provides me with values from a table:
<?php
include "include/connection.php";
$sqlSelect = "SELECT * FROM goodsound";
if(!$executeQuery=mysql_query($sqlSelect)) {
echo mysql_error();
} else {
echo '<div id="videos"> <a href="">new</a>';
while($results=mysql_fetch_array($executeQuery)) {
?>
<ul>
<li>
<div class="cross">+</div>
<?php echo $results['headline']; ?>
</li>
</ul>
<?php
}
echo '</div>';
}
?>
next, I'm trying to implement simple sortable jquery UI function on this list, but it seems to be impossible to move values in a list if they are extracted from a database.
Can someone provide me with a solution? Thanks.... this is my jQuery code:
<script type="text/javascript">
jQuery(function() {
$("#videos ul").sortable({handle:".cross"});
});
</script>
It looks like you're outputting a new ul for every item. You only want to output those before and after your loop.
<?php
include "include/connection.php";
$sqlSelect = "SELECT * FROM goodsound";
if(!$executeQuery=mysql_query($sqlSelect)) {
echo mysql_error();
} else {
echo '<div id="videos"> <a href="">new</a>';
echo '<ul>';
while($results=mysql_fetch_array($executeQuery)) {
?>
<li>
<div class="cross">+</div>
<?php echo $results['headline']; ?>
</li>
<?php
}
echo '</ul>';
echo '</div>';
}
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.