1
<?php
$regs=$_GET["regs"];
$schm=$_GET["schm"];
//echo $regs;
$con = mysql_connect('localhost', 'root', '');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("adjpoly", $con);
$sql="SELECT * FROM student WHERE Register = '".$regs."'";
//echo $sql;
$result = mysql_query($sql);
$sql1="SELECT `Semester`,`Subject`,`Internal`,`External`,`Total`,`Result`,`Arrear` FROM semester".$schm." where Register ='".$regs."'";
//echo $sql1;
$result1 = mysql_query($sql1);
while($row = mysql_fetch_array($result))
{
if($row==NULL)
{
echo '<b style="background-color:#000000">Invalid Number.</b>';
}
else
{
echo "<table style='border:1px solid black;border-collapse:collapse;' width='70%'>
<tr><td style='border:1px solid black;font-weight:bold;background-color:#E2E2E2;font:Tahoma; font-size:13pt' align='right' width='20%'>Name</td>
<td style='border:1px solid black;font-weight:bold;color:#0000CC;background-color:#E2E2E2;font:Tahoma; font-size:13pt'>" . $row['Name']."(". $row['Register']. ")"."</td>
</tr>
<tr><td style='border:1px solid black;font-weight:bold;background-color:#E2E2E2;font:Tahoma; font-size:13pt' align='right' width='20%'>Institution Code</td>
<td style='border:1px solid black;font-weight:bold;color:#0000CC;background-color:#E2E2E2;font:Tahoma; font-size:13pt'>" . $row['Icode'] . "</td>
</tr>
<tr><td style='border:1px solid black;font-weight:bold;background-color:#E2E2E2;font:Tahoma; font-size:13pt' align='right' width='20%'>Course</td>
<td style='border:1px solid black;font-weight:bold;color:#0000CC;background-color:#E2E2E2;font:Tahoma; font-size:13pt'>" . $row['Course'] ."(FULLTIME)"."(". $row['CCode']. ")". "</td>
</tr>
<tr><td style='border:1px solid black;font-weight:bold;background-color:#E2E2E2;font:Tahoma; font-size:13pt' align='right' width='20%'>Scheme</td>
<td style='border:1px solid black;font-weight:bold;color:#0000CC;background-color:#E2E2E2;font:Tahoma; font-size:13pt'>" . $row['Scheme'] . "</td>
</tr>";
echo "</table>";
echo "<B> Result : P - Pass F - Fail A - Absent </B>";
echo "<table style='border:1px solid black;border-collapse:collapse;' width='70%'>
<tr>
<th style='background-color:#0099CC;color:white;font-size:14pt'>Semester</th>
<th style='background-color:#0099CC;color:white;font-size:14pt'>Subject</th>
<th style='background-color:#0099CC;color:white;font-size:14pt'>Internal Mark</th>
<th style='background-color:#0099CC;color:white;font-size:14pt'>External Mark</th>
<th style='background-color:#0099CC;color:white;font-size:14pt'>Total Mark</th>
<th style='background-color:#0099CC;color:white;font-size:14pt'>Result</th>
</tr>";
while($row = mysql_fetch_array($result1))
{
echo "<tr align='center'>";
echo "<td bgcolor='#E2E2E2' style='border: 1px solid black;font:Tahoma; font-size:14pt'>" . $row['Semester'] . "</td>";
echo "<td bgcolor='#E2E2E2' style='border: 1px solid black;font:Tahoma; font-size:14pt'>" . $row['Subject'] . "</td>";
echo "<td bgcolor='#E2E2E2' style='border: 1px solid black;font:Tahoma; font-size:14pt'>" . $row['Internal'] . "</td>";
echo "<td bgcolor='#E2E2E2' style='border: 1px solid black;font:Tahoma; font-size:14pt'>" . $row['External'] . "</td>";
echo "<td bgcolor='#E2E2E2' style='border: 1px solid black;font:Tahoma; font-size:14pt'>" . $row['Total'] . "</td>";
echo "<td bgcolor='#E2E2E2' style='border: 1px solid black;font:Tahoma; font-size:14pt'>" . $row['Result'] . "</td>";
echo "</tr>";
$arr = $row['Arrear'];
}
echo "<tr align='center' bgcolor='#E2E2E2'><td width='100%' colspan='6' style='border: 1px solid black;'> </td></tr>";
echo "<tr align='center' bgcolor='#D7DFE3'><td width='100%' align='center' colspan='6' style='border: 1px solid black;'>Arrear:" .$arr . "</td></tr>";
echo "</table>";
}
}
mysql_close($con);
?>
上面的php代碼可以根據用戶輸入從mysql數據庫中顯示內容。其他部分不顯示來自php的內容
通過使用if語句,驗證給定的輸入是否存在於表中。基於下面的例子的語法。
if($row==NULL)
{
echo "Invalid Input."; // while run, the echo statement not displaying.
}
else
{
o/p part.. //while run, response proper o/p
}
任何人都可以幫助我。請輸入
'while($ row ='掩蓋了if($ row == NULL)'else部分,所以代碼不會到達else。 ,數據庫轉義,或者準備好語句,如果你很聰明的話 – mario 2013-03-17 13:41:18
while()只有在該行等於true時纔會被執行,所以它不能爲null – xdbas 2013-03-17 13:43:23
thnks有任何其他的方式來傳遞我的其他部分msg用戶。? – Hari 2013-03-17 13:53:14