In a form I have I'm trying to have an option to alter the current end date of said auction . Ive come up with this in the pHP code.
What my goal is , as you see with that case : based on the case , the amount I tend to pick to extend said auction , I want to pull the datetime from the Table on my DB, add the amount I so wish, and send it back, properly updated. Thing is Every time I try to update it , it just makes the H:I:S section to '00:00:00'
What the hell is wrong, been going at this for 2 days now.
<?php
/**
* Created by IntelliJ IDEA.
* User: bernardopinheiro
* Date: 02/04/16
* Time: 21:28
*/
include("db.php"); //Establishing connection with our database
$error = ""; //Variable for storing our errors.
$datesql = "";
if(isset($_POST["changeitems"]))
{
$item_id = $_POST['enterid'];
$info = $_POST["picked"];
$datesql = "SELECT data_fim FROM artigos WHERE item_id='$item_id'";
$datequery = mysqli_query($db,$datesql) or die (mysqli_error());
$row = mysqli_fetch_assoc($datequery);
$data_a_actualizar = $row[data_fim];
if ($_POST["taskOption"] == "pname") {
$sql = "UPDATE artigos SET designacao='$info' WHERE item_id='$item_id'";
$query = mysqli_query($db,$sql);
}
elseif ($_POST["taskOption"] == "bvalue") {
$sql = "UPDATE artigos SET valor_base='$info' WHERE item_id='$item_id'";
$query = mysqli_query($db,$sql);
}
elseif ($_POST["taskOption"] == "pdescription") {
$sql = "UPDATE artigos SET descricao='$info' WHERE item_id='$item_id'";
$query = mysqli_query($db,$sql);
}
elseif ($_POST["taskOption"] == "duracao") {
switch ($info) {
case "12":
$data_a_actualizar = strtotime($data_a_actualizar);
$data_a_actualizar = date_modify($data_a_actualizar, "+12 hours");
$data_a_actualizar= date_format($data_a_actualizar,"Y-m-d H:i:s");
$sql = "UPDATE artigos SET data_fim='$data_a_actualizar' WHERE item_id='$item_id'";
$query = mysqli_query($db,$sql);
break;
case "24":
$dataquery = date($dataquery, strtotime('+24 hours'));
$sql = "UPDATE artigos SET data_fim='$dataquery' WHERE item_id='$item_id'";
$query = mysqli_query($db,$sql);
break;
case "48":
$dataquery = date($dataquery, strtotime('+48 hours'));
$sql = "UPDATE artigos SET data_fim='$dataquery' WHERE item_id='$item_id'";
$query = mysqli_query($db,$sql);
break;
}
}
}
This is what im going with at the moment. I've only made changes to the 12h increase case