-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstore_widgets.php
50 lines (38 loc) · 1.35 KB
/
store_widgets.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
$arr = (json_decode($_POST['param']));
$q = $_POST['q'];
$con = mysql_connect( 'localhost', 'root', '' );
mysql_select_db( 'dragndrop', $con );
switch($q)
{
case "update":
print_r($arr);
$sql = "update widgets set header = '" . $arr->header . "' where id = " . $arr->id;
mysql_query( $sql, $con );
break;
case "delete":
print_r($arr);
$sql = "delete from widgets where id = " . $arr->id;
mysql_query( $sql, $con );
break;
default:
$sql = "DELETE
FROM `widgets`";
$result = mysql_query( $sql );
$sql = "INSERT INTO widgets( `header`, `content`, `column`, `order` ) VALUES";
$index = 0;
foreach( $arr as $col )
{
foreach( $col as $widget )
{
if( $index > 0 ) $sql .= ", ";
$sql .= "('" . $widget->header . "', '" . $widget->content . "', '" . $widget->column . "', '" . $widget->order . "' )";
$index++;
}
}
$sql .= ";";
mysql_query( $sql, $con );
break;
}
mysql_close($con);
?>