Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 比较两个下拉列表中的两个不同年份,如果第一年高于第二年,则回显一条消息_Php - Fatal编程技术网

Php 比较两个下拉列表中的两个不同年份,如果第一年高于第二年,则回显一条消息

Php 比较两个下拉列表中的两个不同年份,如果第一年高于第二年,则回显一条消息,php,Php,我想检查,如果我的第一个下拉列表中的年份是2001年,并且在第二个下拉列表中我选择1900年作为年份,那么我将向用户回显一条消息,他应该选择第一个低于第二个的年份(例如:2001当您检查是否提交了数据时,您应该检查年份 if (isset($_POST['id'])) { // All your data if ($start_year > $end_year) { // Echo the error message } else { // If the years are co

我想检查,如果我的第一个下拉列表中的年份是2001年,并且在第二个下拉列表中我选择1900年作为年份,那么我将向用户回显一条消息,他应该选择第一个低于第二个的年份(例如:2001当您检查是否提交了数据时,您应该检查年份

if (isset($_POST['id'])) {

// All your data

if ($start_year > $end_year) {

// Echo the error message

} else {

// If the years are correct, store the data in the database

}

}

希望这能有所帮助。

类似的事情?这完全取决于您。我假设如果您显示错误,您不想更新数据库

if(isset($_POST['id'])){

    $id = $_POST['id'];
    $school = mysql_real_escape_string($_POST["school"]);
    $degree = mysql_real_escape_string($_POST["degree"]);
    $website = mysql_real_escape_string($_POST["website"]);
    $start_date = mysql_real_escape_string($_POST["start_date"]);
    $end_date = mysql_real_escape_string($_POST["end_date"]);
    $start_year = mysql_real_escape_string($_POST["start_year"]);
    $end_year = mysql_real_escape_string($_POST["end_year"]);
    $degree_description = mysql_real_escape_string($_POST["degree_description"]);

    if($start_year > $end_year){
        echo 'The error Message';
        $good = false;
    }else{
        $good = true;
    }

    if($good == true){

        $query="UPDATE education
                SET school = '$school', degree = '$degree', website = '$website', start_date='$start_date', end_date='$end_date', start_year='$start_year', end_year='$end_year', degree_description='$degree_description'
                WHERE id='$id' AND username='$username'";


        mysql_query($query)or die(mysql_error());
        if(mysql_affected_rows()>=0){
            echo "<p>($username) Record Updated<p>";
        }else{
            echo "<p>($username) Not Updated<p>";
        }
    }   
}
else
{
    //first time, initialize as you wish. Probably need to get the first id for this user, using another query
    $id = 0;
}
if(isset($\u POST['id'])){
$id=$_POST['id'];
$school=mysql\u real\u escape\u字符串($\u POST[“school”]);
$degree=mysql\u real\u escape\u字符串($\u POST[“degree”]);
$website=mysql\u real\u escape\u字符串($\u POST[“网站]);
$start\u date=mysql\u real\u escape\u字符串($\u POST[“start\u date”]);
$end_date=mysql_real_escape_字符串($_POST[“end_date”]);
$start\u year=mysql\u real\u escape\u字符串($\u POST[“start\u year”]);
$end_year=mysql_real_escape_字符串($_POST[“end_year”]);
$degree\u description=mysql\u real\u escape\u字符串($\u POST[“degree\u description”]);
如果($start\u year>$end\u year){
回显“错误消息”;
$good=false;
}否则{
$good=true;
}
如果($good==true){
$query=“更新教育”
设置学校=“$school”、学位=“$degree”、网站=“$website”、开始日期=“$start\u date”、结束日期=“$end\u date”、开始年份=“$start\u year”、结束年份=“$end\u year”、学位描述=“$degree\u description”
其中id='$id'和username='$username';
mysql_query($query)或die(mysql_error());
如果(mysql\u受影响的\u行()>=0){
echo“($username)记录已更新”;
}否则{
echo“($username)未更新”;
}
}   
}
其他的
{
//第一次,根据需要初始化。可能需要使用另一个查询获取此用户的第一个id
$id=0;
}
if (isset($_POST['id'])) {

// All your data

if ($start_year > $end_year) {

// Echo the error message

} else {

// If the years are correct, store the data in the database

}

}
if(isset($_POST['id'])){

    $id = $_POST['id'];
    $school = mysql_real_escape_string($_POST["school"]);
    $degree = mysql_real_escape_string($_POST["degree"]);
    $website = mysql_real_escape_string($_POST["website"]);
    $start_date = mysql_real_escape_string($_POST["start_date"]);
    $end_date = mysql_real_escape_string($_POST["end_date"]);
    $start_year = mysql_real_escape_string($_POST["start_year"]);
    $end_year = mysql_real_escape_string($_POST["end_year"]);
    $degree_description = mysql_real_escape_string($_POST["degree_description"]);

    if($start_year > $end_year){
        echo 'The error Message';
        $good = false;
    }else{
        $good = true;
    }

    if($good == true){

        $query="UPDATE education
                SET school = '$school', degree = '$degree', website = '$website', start_date='$start_date', end_date='$end_date', start_year='$start_year', end_year='$end_year', degree_description='$degree_description'
                WHERE id='$id' AND username='$username'";


        mysql_query($query)or die(mysql_error());
        if(mysql_affected_rows()>=0){
            echo "<p>($username) Record Updated<p>";
        }else{
            echo "<p>($username) Not Updated<p>";
        }
    }   
}
else
{
    //first time, initialize as you wish. Probably need to get the first id for this user, using another query
    $id = 0;
}