[Pugged] RE: Moving Up and Down
Chris Hettinger
ciapug@ciapug.org
Wed, 11 Sep 2002 15:48:39 -0500
Okay... run over my process here (Moving a forum Up 1 slot):
// Select forum to be moved.
$sql =3D "SELECT * FROM frmForums WHERE frmID =3D $f";
$rsForums =3D result set
// Assign comparison values
$moveID =3D $rsForums->fields['frmID'];
$oldPos =3D $rsForums->fields['frmPosition'];
// Update the record to be moved to position 0
$sql =3D 'UPDATE frmForums SET frmPosition =3D 0 WHERE frmID =3D =
$f ';
// Select the record just previous
// needs to be within the same category... check for the catID to match =
as well.
$sql =3D "SELECT * FROM frmForums WHERE catID =3D =
$rsForums->fields['catID']; AND frmID =3D $f - 1";
$rsPrevious =3D result set
// Update this records position +1
$sql =3D 'UPDATE frmForums SET frmPosition =3D =
$rsPrevious->fields['frmPosition'] + 1 WHERE frmID =3D =
$rsPrevious->fields['frmID']; =20
// Set the initial forum record's ($moveID) position ($oldPos) - 1
$sql =3D 'UPDATE frmForums SET frmPosition =3D $oldPos - 1 WHERE =
frmID =3D $moveID;