Darathor
Dans "includes/fonctions.php" :
Code :
#
# Trouver
#
?>
#
# Ajouter avant
#
// DEBUT MOD Reorder function
/**
* Bouche les trous dans l'ordonancement.
*
* Inspiré de la fonction renumber_order du fichier admin_forums.php.
*
* $table : table concernée.
* $orderfield : champ sur lequel est fait l'ordonancement.
* $idfield : champ clé de la table.
* $firstpos : position du premier élément.
* $where : contenu de la clause where, si besoin.
*/
function reorder_elements($table, $orderfield, $idfield, $firstpos = 1, $where = '')
{
global $db;
$sql = "SELECT * FROM $table";
if($where != '')
{
$sql .= " WHERE $where";
}
$sql .= " ORDER BY $orderfield ASC";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't get list of elements", "", __LINE__, __FILE__, $sql);
}
$i = $firstpos;
while($row = $db->sql_fetchrow($result))
{
$sql = "UPDATE $table
SET $orderfield = $i
WHERE $idfield = " . $row[$idfield];
if( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't update order elements", "", __LINE__, __FILE__, $sql);
}
$i++;
}
}
// FIN MOD Reorder function