使用PHP我想从信用列中减去使用过的列的每个值.我在phpmyadmin中创建了一个tableA.
剩余:信用 - 我无法得到结果我只是得到相同的信用值.
// The desire output in table A
id |date |credit |used|remaining|
1 |20-5-2013 |400 |300 |100 |
2 |19-5-2013 |300 |100 |200 |
3 |18-5-2013 |600 |50 |550 |
// db connection
query select all from tableA
$sql = "SELECT * FROM tableA";
$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
?>
fetch the information and output into a table:
<table >
<tr>
bla bla..
</tr>
// echo:
<tr> …Run Code Online (Sandbox Code Playgroud) 我想抛出一个异常,以使用户知道年龄值输入应在1到120之间。在下面的示例中查找。
有没有更好的方法引发异常?
public class Lesson18Encapsulation3 {
private int age;
private String name;
private int salary;
public int getAge() {
return age;
}
public void setAge(int age) {
if ( age < 0 && age >= 120)
this.age = age;
throw new IllegalArgumentException (" age can not be negative or more than 120");
//getters and setters
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Run Code Online (Sandbox Code Playgroud)
public class Lesson18Encapsulation3 {
private int age; …Run Code Online (Sandbox Code Playgroud)