我正在准备一些陈述,并希望在更新之前检查该行是否存在。如果它存在则更新它,如果它没有输出消息"没有这样的动物"。我有更新位工作,但不知道如何检查行是否存在。请协助。
$v = array();
$v[] = $_POST['status'];
$v[] = $_POST['id'];
$dbh = dbh_get();
$sql = 'UPDATE tap SET status=?
WHERE id =?';
$stmt = $dbh->prepare($sql);
$stmt->execute($v);
\\ if row isn't there display message "No such animal"
\\ otherwise print the below
printf("Status was changed to - %s", $v[0]);
\\then either way have my continue button for me to click on
print '<div class="button" style="float:left;" onclick="window.location.href=\'admin.php\';">Admin</div>' . "\n";
dbh_free($dbh)
答案 0 :(得分:1)
根据您的问题,您希望在执行更新之前检查该行是否存在。你可以试试这个 -
for i := 0 to CheckListBox1.Items.Count - 1 do
begin
if CheckListBox1.Checked[i] = True then
begin
p1 := '';
p2 := '';
p3 := '';
Memo1.Lines.Append(CheckListBox1.Items.Strings[i]);
if i = 0 then begin
p1 := 'Disease 1';
p2 := 'Disease 2';
p3 := 'Disease 3';
end;
...
Memo1.Lines.Add('Disease:' + p1+', '+p2+', '+p3);
Memo1.Lines.Add('');
end;
end;
end;