我有一个将结果数据输出到表中的查询。我在该表中有两个字段对于此if
语句至关重要:Max Capacity
和Current Capacity
. 这些来自我们的数据库,来自同一张表。
我想写一个if
声明:
if (Max_C == Current_C){
echo "Sorry, course is full.";
}
else{
$insert = mysql_query ("insert into blahblahblah... ");
}
我该怎么做呢?如何从数据库中指定max_c
和current_c
?
那段代码:
if($courseandtime) { $max_e = $courseandtime['MaxEnrollment']; $current_e = $courseandtime['COUNT(REGISTERED.SID)']; }
if ($current_e < $max_e) {
echo "
<form action='register-exec.php' method='post'>
<label>Time: $_POST[Time]</label><br>
<input type='hidden' value='$Time' /><br><br>
<label>Student ID:</label><br>
<input type='text' name='SUCID' id='SUCID' /><br><br>
<label>CID: $_POST[CID]</label><br>
<input type='hidden' name='CID' id='CID' /><br><br>
<label>SID: $row['SID']</label><br>
<input type='hidden' name='SID' id='SID' /><br><br>
<button type='submit'>Register</button>
</form>
";
}
else {
echo 'Sorry, were full!';
}