Tuesday, 15 January 2013

php - Drag and drop feature of sorting my categories -



php - Drag and drop feature of sorting my categories -

i utilize kohana in e-commerce application.

i have catalogue of categories.

i want find module in box drag , drop feature sort categories. know php scripts, modules based on kohana, zend, etc.?

try this: http://www.webresourcesdepot.com/dynamic-dragn-drop-with-jquery-and-php/

fyi: code in above link uses foreach loop update each record, resource consuming...

foreach ($updaterecordsarray $recordidvalue) { $query = "update records set recordlistingid = " . $listingcounter . " recordid = " . $recordidvalue; mysql_query($query) or die('error, insert query failed'); $listingcounter = $listingcounter + 1; }

you can utilize reliable code this:

$casessql = ''; $idvalues = array(); foreach ($order $ordernum => $idvalue) { $casessql .= " when '" . $idvalue . "' '" . ($ordernum + 1) . "'"; $idvalues[] = $idvalue; } $sql = "update `" . $table . "`" . " set `displayorder` = case `" . $idfield . "`" . $casessql . " end" . " `" . $idfield . "` in (" . implode(', ', $idvalues) . ")";

which uses 1 query update whole records updated, $order like:

array ( [0] => 2 [1] => 1 [2] => 4 [3] => 3 )

php zend-framework kohana

No comments:

Post a Comment