title: Trying to select from database and insert default value
body: <p>I'm trying to figure how to select from database and add the default value when pressing a button. What I'm trying to say is when the button is pressed it would select the table it would insert default values?</p>
  
  <pre><code>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 &gt;= '$from' ";
      if ($to_date != "")
          $sql .= " AND tran_date &lt;= '$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).")";
  }
  </code></pre>