English 中文(简体)
以往更新的记录在更新新纪录时再次出现。
原标题:Previous updated record reverts when updating a new record MySQL PHP

人人有好天。 我试图为我的系统提供任务跟踪模块。 逻辑是,每当我向用户分配任务时,该系统将任务更新到“信号”的含义,即特定用户负责这项任务。 更新后,它创建了一个“用户_task”表,基本上把任务和用户表联系在一起。 每当我给某个人指派任务时,就会被罚款。 但是,当我再次这样做时,以前的任务记录是,Istaken的田地回到零。 我试图重新签字,但先前的记录再次重述。 它令人非常不安。 I m 采用XAMPP、MySQL和PHP。 我不喜欢我,不是唯一经历过这种情况的人。 任何帮助都会受到高度赞赏。

我的表格如下:

CREATE TABLE IF NOT EXISTS `task` (
  `Task_No` int(11) NOT NULL AUTO_INCREMENT,
  `Task_Name` varchar(100) NOT NULL,
  `Task_Desc` varchar(450) DEFAULT NULL,
  `Task_DateCreated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `Task_IsTaken` tinyint(1) NOT NULL,
  PRIMARY KEY (`Task_No`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

CREATE TABLE IF NOT EXISTS `user_task` (
  `UT_No` int(11) NOT NULL AUTO_INCREMENT,
  `User_Email` varchar(100) NOT NULL,
  `Task_No` int(11) NOT NULL,
  `Task_Duration` varchar(20) NOT NULL,
  `Task_DateTaken` date DEFAULT NULL,
  `Task_DateFinished` timestamp NULL DEFAULT NULL,
  `Task_IsIssue` tinyint(1) NOT NULL,
  PRIMARY KEY (`UT_No`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

我的文字(从形式上):

//Process - Insert Task
if(isset($_POST[ btnCreateTask ]))
{
if($_POST[ taskName ]!=NULL)
{
$taskName = mysql_real_escape_string ($_POST[ taskName ]);
$taskDesc = mysql_real_escape_string ($_POST[ taskDesc ]);
$insertTask = "INSERT INTO task(Task_Name, Task_Desc, Task_IsTaken) VALUES( $taskName ,  $taskDesc , 0)";
$sqlResult1 = mysql_query($insertTask);}
else
{
    echo "No task name given";
    $errorCode = 1;
}
}


if(isset($_POST[ btnAssignTask ]))
{
    if($_POST[ assignTaskName ]!=NULL)
{
    $assigntaskName = mysql_real_escape_string($_POST[ assignTaskName ]);
    $assigntaskNo = mysql_real_escape_string($_POST[ assignTaskNo ]);
    $assigntaskOwner = mysql_real_escape_string($_POST[ assignTaskOwner ]);
    $assigntaskDuration = mysql_real_escape_string($_POST[ assignTaskDuration ]);
    $updateUpcomingTask = "UPDATE task SET Task_IsTaken =  1  AND Task_No =  $assigntaskNo ";
    $createUserTask = "INSERT INTO user_task (User_Email, Task_No, Task_Duration, Task_DateTaken, Task_DateFinished) 
                        VALUES ( $assigntaskOwner ,  $assigntaskNo ,  $assigntaskDuration ,  $now , NULL)";
    $sqlResult2 = mysql_query($updateUpcomingTask);
    $sqlResult3 = mysql_query($createUserTask);
}
else
{
    echo "No task selected";
    $errorCode = 2;
}
}
最佳回答

你的法典应当改为:

if(isset($_POST[ btnAssignTask ]))
{
    if($_POST[ assignTaskName ]!=NULL)
{
    $assigntaskName = mysql_real_escape_string($_POST[ assignTaskName ]);
    $assigntaskNo = intval($_POST[ assignTaskNo ]);
    $assigntaskOwner = mysql_real_escape_string($_POST[ assignTaskOwner ]);
    $assigntaskDuration = mysql_real_escape_string($_POST[ assignTaskDuration ]);
    $updateUpcomingTask = "UPDATE task SET Task_IsTaken =  1  WHERE Task_No = $assigntaskNo";
    $createUserTask = "INSERT INTO user_task (User_Email, Task_No, Task_Duration, Task_DateTaken, Task_DateFinished) 
                    VALUES ( $assigntaskOwner ,  $assigntaskNo ,  $assigntaskDuration ,  $now , NULL)";
    $sqlResult2 = mysql_query($updateUpcomingTask);
    $sqlResult3 = mysql_query($createUserTask);
}
else
{
    echo "No task selected";
    $errorCode = 2;
}
}
问题回答

暂无回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签