I have container with div like this:
<div class="container">
<div class="step" id="1">
<h2 class="title">Step 1</h2>
<div class="image" id="1">Item 1</div>
<div class="image" id="2">Item 2</div>
<div class="image" id="3">Item 3</div>
</div>
<div class="step" id="2">
<h2 class="title">Step 2</h2>
<div class="image" id="4">Item 4</div>
<div class="image" id="5">Item 5</div>
<div class="image" id="6">Item 6</div>
</div>
<div class="step" id="3">
<h2 class="title">Step 3</h2>
<div class="image" id="7">Item 7</div>
<div class="image" id="8">Item 8</div>
<div class="image" id="9">Item 9</div>
</div>
</div>
Basically I have script that is taking note of drag and drop and notes changes in div.step class. See Image for better Understanding
$.ajax({
type: 'POST',
url: 'process.php',
data: {json: JSON.stringify(myArguments)},
dataType: 'json'
});
I don't know how to take this further in process.php
Any way to separate step id and class id as shown in image above so i can insert in database
Thank You.
Edit: Update process.php (Working Now Thanks To Ofir Baruch)
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "testdb";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$json = $_POST['json'];
$organize = json_decode($json);
foreach($organize->{1} as $pos => $div){
$pos1 = 1;
$sql = "INSERT INTO process VALUES (DEFAULT,'".mysqli_real_escape_string($conn,$pos1)."','".mysqli_real_escape_string($conn,$div)."')";
if ($conn->query($sql) === TRUE) {
}
//Insert to the Database:
// Step: 1
// image_id: $div
// position: $pos
}
foreach($organize->{2} as $pos => $div){
//Insert to the Database:
// Step: 2
// image_id: $div
// position: $pos
$pos1 = 2;
$sql = "INSERT INTO process VALUES (DEFAULT,'".mysqli_real_escape_string($conn,$pos1)."','".mysqli_real_escape_string($conn,$div)."')";
if ($conn->query($sql) === TRUE) {
}
}
foreach($organize->{3} as $pos => $div){
//Insert to the Database:
// Step: 3
// image_id: $div
// position: $pos
$pos1 = 3;
$sql = "INSERT INTO process VALUES (DEFAULT,'".mysqli_real_escape_string($conn,$pos1)."','".mysqli_real_escape_string($conn,$div)."')";
if ($conn->query($sql) === TRUE) {
}
}
?>
