aboutsummaryrefslogtreecommitdiff
path: root/admin/newsreel/updateDB.php
blob: 0e5efda111fc52b67ea59a79c7b5b1faa0d75473 (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
41
42
43
44
45
46
47
48
49
<?php

//basename(dirname('.'))
$dirname = "/path/to/bayonet/here";

define('BAYONET_ROOT', $dirname);
define('BAYONET_INCLUDE', BAYONET_ROOT . '/include');
define('BAYONET_CONFIG', BAYONET_ROOT . '/include/config.ini');

require BAYONET_INCLUDE . '/debug.php';
require BAYONET_INCLUDE . '/sql.class.php';
require BAYONET_INCLUDE . '/functions.php';

Bayonet_Config::init();
$config = Bayonet_Config::$ini;
$db = new Bayonet_SQL();


//Connect to the MySQL server
$db->Connect($config['sql']['hostname'], $config['sql']['username'], $config['sql']['password']);
$db->Select_db($config['sql']['database']);

/*----------------------------- */

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

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());
?>