asked on
ASKER
ASKER
ASKER
// ID of record to move
$headline_id = $_GET['id'];
// Get move direction up/down... -1/1
$direction = $_GET['reorder'] == "down" ? "+ 1" : "- 1";
// Get records values
$target_ID = mysql_fetch_array(mysql_query(" SELECT ticker_ID from ticker where rank = (( SELECT rank from ticker where ticker_ID = $headline_id ) $direction ) "));
$value1 = mysql_fetch_array(mysql_query(" SELECT rank from ticker where ticker_ID = $headline_id"));
$value2 = mysql_fetch_array(mysql_query(" SELECT rank from ticker where ticker_ID = {$target_ID['ticker_ID']}"));
// Debug
echo "direction: ".$direction."<br>";
echo "val1 = ".$value1['rank']."<br>";
echo "val2 = ".$value2['rank']."<br>";
echo "headline = ".$headline_id."<br>";
echo "target = ".$target_ID['ticker_ID']."<br>";
// Update
mysql_query("UPDATE ticker SET rank = {$value2['rank']} WHERE ticker_ID = $headline_id"); // set new rank
// all other functional code to properly update the list was commented out for testing
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY