aboutsummaryrefslogtreecommitdiff
path: root/admin/newsreel/updateDB.php
blob: f4031a2261b8fa642bbb582faf6bb575271a1e3b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

include '../../includes/debug.php';
include '../../includes/config.php'; 
include '../../includes/sql.class.php';
include '../../includes/functions.php';

$action = $_POST['action'];
$updateRecordsArray = $_POST['recordsArray'];

$db = new Bayonet_SQL();
$db->Connect(
  $config['sql']['hostname'],
  $config['sql']['username'],
  $config['sql']['password']
  );
$db->Select_db($config['sql']['database']);

if ($action == "updateReelOrder"){

	$listingCounter = 1;
	foreach ($updateRecordsArray as $recordIDValue) {
	
		$db->Query("UPDATE `bayonet_newsreel` SET `weight` = '$listingCounter' WHERE `slide_id` = '$recordIDValue'");
		$listingCounter = $listingCounter + 1;
	}
	echo "<img src=\"images/accepted.png\" />";
/*
	echo '<pre>';
	print_r($updateRecordsArray);
	echo '</pre>';
	echo 'If you refresh the page, you will see that records will stay just as you modified.';
*/
}
else{
	echo "<img src=\"images/rejected.png\" />";
}
date_default_timezone_set("America/New_York");
echo " Updated at ".date("g:i:s a", time());
?>