我想使用 ajax 和 php 创建一个带有文本框的输入面板,它应该在一个表中验证给定的 id,如果 id 有效,则在另一个表中插入 id、日期、时间、状态
select id="$id" from table1 if id valid insert into table 2 '&id','&date','&time_stamp','&status'
我认为的示例查询。 为此,我需要代码,请帮助我
id | date | time |status
:----- | -----: | :----:|-----|
2345 | 21/01/2017 | 12:13 am|in |
please validate the above example and help me in writing the correct query
最佳答案
我建议是这样的:
在 PHP 中(在这样的查询中验证 id):
select id from table1 where id = $id
如果查询返回任何内容,继续下一个查询:
insert into table2 (value1, value2, value3) values ($v1, $v2, $v3)
jQuery 端:
$.get("query.php", {id:id}).done(function(res){
if (res.status=="success") alert("success");
else alert("failed");
}
关于php - 我想检查一张 table 上的人是否有效输入他的出勤率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41782177/