-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_post_batch.php
More file actions
40 lines (36 loc) · 1.03 KB
/
Copy pathedit_post_batch.php
File metadata and controls
40 lines (36 loc) · 1.03 KB
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
<?php
include_once('db_conn.php');
$conn = connect_to_db();
mysqli_query("SET SESSION sql_mode = 'NO_ENGINE_SUBSTITUTION'");
$query = $conn->prepare("UPDATE posts SET make = ?, model = ?, year = ?, price = ?, mileage = ?, city = ?, state = ?, VIN = ? WHERE post_id = ?");
$query->bind_param("ssiiisssi",$make,$model,$year,$price,$miles,$city,$state,$vin,$post_id);
$post_ids = $_POST['post_id'];
$makes = $_POST['make'];
$models = $_POST['model'];
$years = $_POST['year'];
$prices = $_POST['price'];
$mileses = $_POST['miles'];
$cities = $_POST['city'];
$states = $_POST['state'];
$vins = $_POST['vin'];
$i = 0;
$conn->autocommit(FALSE);
foreach($post_ids as $post_id) {
$make = $makes[$i];
$model = $models[$i];
$year = $years[$i];
$price = $prices[$i];
$miles = $mileses[$i];
$city = $cities[$i];
$state = $states[$i];
$vin = $vins[$i];
if(!$query->execute()) {
echo 'Batch update failed: '.$conn->mysqli_error();
$conn->rollback();
die;
}
$i++;
}
echo 'Batch update successful';
$conn->commit();
?>