I am using sort table rows with jQuery using drag and drop method for table sort. Now the issue I am facing is after saving order to DB how can I set the table on refresh page or load?
Means my table is in HTML and I can get order from db in PHP but how can reorder with that sort? My table structure is like :
`order`->fields ('id'=> int,'order'=>int,'code'=>int)
While in above MySQL table order is used for table row reordering and code for unique table. I am confused and don't know how to sort out this issue.
Edit3: I deleted a bunch of the stuff i just had, so if you want to see it agian just let me know and i'll send it to you, but this should answer your question:
i see that you said your HTML is already set. Thats an easy fix. Load your html via php like so:
<?
$STH = $DBH->query('SELECT * FROM <table> ORDER BY order');
$STH->setFetchMode(PDO::FETCH_ASSOC);
echo '<div id = "tablediv"><table>
<tr>
<th>My Table Header</th>
</tr>';
while($row = $STH->fetch())
{
echo '<tr>';
echo '<td>My DB Data Via String Concat</td>';
echo '</tr>';
}
echo'</table>';
echo'</div>';
?>
Basically just loop through your mysql result and create table rows based on how many there are with a simple php while loop.
edit 4: added PDO security as suggested by tadman
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.