dsc862009 2016-05-23 15:32
浏览 10

根据Form(php)中的选项更改日期时间

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
    • ¥15 opencv图像处理,需要四个处理结果图
    • ¥15 无线移动边缘计算系统中的系统模型
    • ¥15 深度学习中的画图问题
    • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
    • ¥15 Python报错怎么解决
    • ¥15 simulink如何调用DLL文件
    • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
    • ¥30 线性代数的问题,我真的忘了线代的知识了
    • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统