The first half of my issue has been resolved. Following is a script that allows you to dynamically sort a recordset.
Now I need to update the records. After the main script, the original ColdFusion update script is included for reference.
<!-- Original collection of scripts by http://www.triplezero.com.au/ -->
<html>
<head>
<title>Dynamically Rearrange Record Sequence</title>
</head>
<body>
<?php
$dbconnect=mysql_connect ("localhost", "name", "password") or die ('I cannot connect to the database.');
mysql_select_db ("database");
$db="database";
$query="SELECT gallery_id, gallery_name, gallery_description, gallery_seq FROM table ORDER BY gallery_seq";
$result = mysql_db_query($db,$query,$dbconnect) or die ("Could not execute query: $query. " . mysql_error());
$recordcount=mysql_num_rows($result);
?>
<p>Select the item you'd like to move, and use the <strong>up</strong> and <strong>down</strong> links to move it.</p>
<script>
function move(foo,way) { j=-1; menuLen=foo.length;
if (way=='up') { lim=0; m=-1 } else { lim=menuLen-1; m=1 };
for (i=0;i<menuLen;i++) if (foo.options.selected) { j=i; i=menuLen; }
if (j==-1) alert('Nothing is selected.'); else if (j==lim) alert('You can\'t go '+way+' any further.')
else { k=j+m; tempt=foo.options[k].text; tempv=foo.options[k].value;
foo.options[k].text=foo.options[j].text
foo.options[k].value=foo.options[j].value
foo.options[j].text=tempt; foo.options[j].value=tempv;
foo.options[j].selected=false;
foo.options[k].selected=true; } }
function showMenu(foo) { temp=''; menuLen=foo.length; comma=''
for (i=0;i<menuLen;i++) { j=i+1; temp += comma + foo.options.value; comma=',' }
document.theForm.theResults.value=temp
}
</script>
<form name=theForm action="change.php" method="post" onSubmit="showMenu(document.theForm.theMenu)">
<p><a href="javascript:move(document.theForm.theMenu,'up')">up</a></p>
<input type=hidden name=theCount value="<?php echo "$recordcount"; ?>">
<input type=hidden name=theResults value="">
<p><select name="theMenu" size="<?php echo "$recordcount"; ?>">
<?php while(list($gallery_id, $gallery_name, $gallery_description, $gallery_seq) = mysql_fetch_row($result)) { ?>
<option value="<?php echo "$gallery_id"; ?>"><?php echo "$gallery_seq - $gallery_name - $gallery_description"; ?></option>
<?php } ?>
</select></p>
<p><a href="javascript:move(document.theForm.theMenu,'down')">down</a></p>
<p><input type=submit name=submit value="rearrange"></p>
</form>
</body>
</html>
************
<html>
<head>
<title>Updating New Record Sequence</title>
</head>
<body>
<cfparam name="form.submit" default="">
<cfif findnocase('rearrange', form.submit)>
<cfloop index="loopitem" from="1" to="#form.thecount#" step="1">
<cfquery name=changesequence datasource="#db#">
update content
set contentseq = #loopitem#
where contentid = #listgetat(theresults, loopitem)#
</cfquery>
</cfloop>
<cfinclude template="This file displays the sequence">
<cfelse>
<cfinclude template="This file displays the sequence">
</cfif>
</body>
</html>
**************
The small script above is where the revised records are updated in the database. Can anyone translate this into PHP? Many thanks!