我有一个 mysql 表,其中有 2 个字段,
1)Id
2)Name.
我想Id, Name
从同一个表中获取数据,但除了当前行的 id 之外,应该获取所有记录的 ID。
尝试这个
if(isset($_POST['flag']) && $_POST['flag'] == 'check_department') {
$name = $_POST['name'];
$row = count_records_sql("SELECT COUNT() as count FROM ".$CFG->prefix."department WHERE name ='".$name."' AND status='active'");
if($row !=0) {
echo "true";
} else {
echo "false";
}
if(isset($_GET['flag']) && $_GET['flag']=='edit') {
$edit_id=$_GET['edit_id'];
$row = count_records_sql("SELECT COUNT() as count FROM ".$CFG->prefix."department WHERE name ='".$name."' AND id != '".$id(1)."' AND status='active'");
if($row !=0) {
echo "true";
} else {
echo "false";
}
}
}