我试图弄清楚如何从数据库中选择并按下按钮时添加默认值。我要说的是,当按下按钮时会选择要插入默认值的表吗?
function budget_item($from_date, $to_date, $account) {
$from = date2sql($from_date);
$to = date2sql($to_date);
$sql = "SELECT SUM(amount)
FROM ".TB_PREF."budget
WHERE account=".db_escape($account);
if ($from_date != "")
$sql .= " AND tran_date >= '$from' ";
if ($to_date != "")
$sql .= " AND tran_date <= '$to' ";
$result = db_query($sql,"No budget were returned");
$row = db_fetch_row($result);
return $row[0];
$sql = "INSERT INTO ".TB_PREF."budget(
account) VALUES ('$date',
".db_escape($account).",".db_escape($amount).")";
}