forked from Luis-J-Ianez/cubecomps.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
switcheventfld.php
33 lines (31 loc) · 1.04 KB
/
switcheventfld.php
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
<?
require_once "lib.php";
require_once "lib_ref_admin.php";
require_once "lib_get.php";
$_GETid = _GET_num("id");
$_GETfld = _GET_fld("fld");
if ($_GETid && $_GETfld)
{
require_once "db.php";
//
$result = strict_query("SELECT * FROM $eventstable WHERE id=?", array($_GETid));
if (sql_num_rows($result)==1)
{
$fld = substr($_GETfld,strpos($_GETfld,"_"));
switch ($fld)
{
case "_format":
$formats = strict_query("SELECT * FROM formats ORDER BY id");
while($row=cased_mysql_fetch_array($formats)) $fmts[] = $row["name"];
$category = strict_query("SELECT possible_formats FROM categories WHERE id=".cased_mysql_result($result,0,"id"));
$possible_formats = cased_mysql_result($category,0,"possible_formats");
$value = cased_mysql_result($result,0,$_GETfld);
$newValue = (int)substr ($possible_formats, (strpos($possible_formats,"".$value)+1) % strlen($possible_formats), 1);
strict_query("UPDATE $eventstable SET $_GETfld=$newValue WHERE id=?", array($_GETid));
echo $fmts[$newValue-1];
break;
}
}
sql_close();
}
?>