我需要mysql数据库包含20个记录,每个特定的日期,如果用户试图输入更多的数据,已经有20个记录,...i希望程序拒绝该输入,并提示用户输入另一个日期
这就是我尝试过的
select count($hopeid)from clinics
Where $date > midnight today and $date < 1159pm tonight and $hopeid =(hopeid)
if results < 20 then
mysql_query("INSERT INTO clinics(hopeid, date, time, appttype, newonARV,newfile,txtname)
VALUES
('$hopeid','$date','$time','$appttype','$newonARV','$newfile','$txtname')") or die(mysql_errno());
else {
Echo"this date is full please choose another date";(mysql_errno();
}发布于 2014-03-29 01:49:44
可以在SQL查询中放置WHERE条件,如下所示
检查this
执行查询后,使用mysql_affected_rows()测试插入是否成功
if(mysql_affected_rows()==1){
echo "Inserted..!";
}else if(mysql_affected_rows()==0){
echo "this date is full please choose another date";
}else{
echo "error:".mysql_error();
}发布于 2014-03-29 01:52:25
选择日期后,调用Ajax找到该日期内的编号记录,如果是20多条记录,当天显示某条消息,一条消息中已经有20条记录,并添加这条新记录作为date+1,因此它将转到下一个日期,这样用户很容易理解
发布于 2014-03-29 01:52:37
$result = mysql_fetch_array(mysql_query("select hopeid from clinics
WHERE " . $date . " BETWEEN '18/03/2011' AND '18/09/2011'"));
$result = sizeOf($result);
if ($result < 20){
mysql_query("INSERT INTO ... bla bla ...);
} else {
echo "this date is full please choose another date";
}https://stackoverflow.com/questions/22719842
复制相似问题