<?php
$conn = mysql_connect ( 'localhost', 'root', 'admin' ) or die ( 'could not connect: ' . mysql_error () );
mysql_select_db ( 'sybgtjxt' ) or die ( 'could not select database' );
mysql_query ( "set names gbk" );
?>
<caption>
<h2>布置作業</h2>
</caption>
<tr>
<th style="text-align: left">課程名稱:</th>
<td><input type="text" name="cname" id="cname"
style="border-color: #FCC898; border-width: 3px; border-style: solid; font-weight: normal; width: 400px;">
</td>
</tr>
<tr>
<th style="text-align: left">任課老師:</th>
<td><select name="tname" id="tname">
<option value='0' selected>請選擇</option>
<?php
$sql = "select tname from tblteacher";
$result = mysql_query ( $sql );
while ( $row = mysql_fetch_assoc ( $result ) ) {
?>
學 院:
請選擇
<?php
$sql = "select colname from college";
$result = mysql_query ( $sql );
while ( $row = mysql_fetch_assoc ( $result ) ) {
?>
專 業:
請選擇
<?php
$sql = "select pro_name from pro";
$result = mysql_query ( $sql );
while ( $row = mysql_fetch_assoc ( $result ) ) {
?>
年 級:
請選擇
<?php
$sql = "select sgrade from tblstudent";
$result = mysql_query ( $sql );
while ( $row = mysql_fetch_assoc ( $result ) ) {
?>
截止日期:
年
月
日
<tr>
<th style="text-align: left">實驗名稱:</th>
<td><input type="text" name="pname" id="pname"
style="border-color: #FCC898; border-width: 3px; border-style: solid; font-weight: normal; width: 400px;">
</td>
</tr>
<tr>
<th style="text-align: left">實驗目的:</th>
<td><textarea cols="58" rows="4" name="paim" id="paim"
cellspacing="0"
style="border-color: #FCC898; resize: none; border-width: 3px; border-style: solid; font-weight: normal; width: 400px;"></textarea>
</td>
</tr>
<tr>
<th style="text-align: left">實驗內容:</th>
<td><textarea cols="58" rows="4" name="pcontent" id="pcontent"
cellspacing="0"
style="border-color: #FCC898; resize: none; border-width: 3px; border-style: solid; font-weight: normal; width: 400px;"></textarea>
</td>
</tr>
<tr>
<th style="text-align: left">實驗步驟:</th>
<td><textarea cols="58" rows="4" name="pstep" id="pstep"
cellspacing="0"
style="border-color: #FCC898; resize: none; border-width: 3px; border-style: solid; font-weight: normal; width: 400px;"></textarea>
</td>
</tr>
<tr>
<th style="text-align: left">實驗結果:</th>
<td><textarea cols="58" rows="4" name="presult" id="presult"
cellspacing="0"
style="border-color: #FCC898; resize: none; border-width: 3px; border-style: solid; font-weight: normal; width: 400px;"></textarea>
</td>
</tr>
<tr>
<th style="text-align: left">分析討論:</th>
<td><textarea cols="58" rows="4" name="panalyse" id="panalyse"
cellspacing="0"
style="border-color: #FCC898; resize: none; border-width: 3px; border-style: solid; font-weight: normal; width: 400px;""></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="提交"> <input
type="reset" value="重置" onclick="Reset()"></td>
</tr>
</table>
</form>
js裡驗證非空2種方式 第一種判斷長度是不是大於0 即length>0
第二個 比對 =='' 或者 !=null