Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ช่วยด้วยค่ะ เรื่องการดึงข้อมูลมาแสดงแล้วให้เปลี่ยนสี ค่ะ



 

ช่วยด้วยค่ะ เรื่องการดึงข้อมูลมาแสดงแล้วให้เปลี่ยนสี ค่ะ

 



Topic : 015818

Guest




คือ ทำแสดงผลสอบของนักเรียนผ่านเว็บนะค่ะ
คือ หากว่านักเรียนสอบผ่าน อยากให้เป็นสีนำเงิน
แต่ถ้าหากนักเรียนสอบตก ให้เป็นสี แดงนะค่ะ เช่นว่า
คะแนน เต็ม 50 ถ้านักเรียนสอบได้ 28 ถือว่าผ่าน แต่ถ้าหากต่ำกว่า 28 ถือว่าไม่ผ่านค่ะ

ข้อมูลเก็บไว้ใน Mysql

ที่ทำอย่างนี้นะค่ะ ช่วยดูให้หน่อยได้ไหมค่ะ ว่าจะต้องเติมอะไรตรงไหน

<html>
<head>
<title>""</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>
<html>
<body bgcolor="#FFFFFF">
<table width="550" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><form name="form1" method="post" action="search.php">
<div align="center">ชื่อที่ต้องการค้นหา
<input type="text" name="keyword" value="<? echo"$keyword"; ?>">
<select name="fields">
<option value="code" selected>รหัสนักศึกษา</option>
</select>
<input type="submit" name="Submit" value="ค้นหา">
&nbsp;<a href="#"onClick="window.close()"><img src="../button/close1.jpg" alt="ยกเลิก" width="69" height="20" border="0" align="absmiddle"></a>
</div>
</form></td>
</tr>
</table>
<?
if (empty($keyword) or empty($fields))
{
echo"กรุณาเลือกรายการค้นหา ด้วยครับ";
exit();
}
else
{
$host="localhost";
$username="";
$password="";
$db="";
$tb="";
mysql_connect( $host,$username,$password) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");

mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้"); /* ทำการเลือกฐานข้อมูลก่อน */

$sql="SELECT * FROM $tb where $fields like '%$keyword%'";

$db_query=mysql_db_query($db,$sql);

$num_rows=mysql_num_rows($db_query); /* นับ Reccord ที่พบ */
if(empty($num_rows)) /* ตรวจสอบว่ามีอยู่หรือยัง */
{
echo"<center><br>ไม่พบข้อมูล <b>$keyword</b> หรือไม่มีรหัสนักศึกษานี้ <b> <b> </center>";
exit();
}
else
{

$a=0;
while($a < $num_rows)
{
$result = mysql_fetch_array($db_query);
$code=$result[code];
$name=$result[name];
$sername=$result[sername];
$g1=$result[g1];
$g2=$result[g2];
$g3=$result[g3];
$g4=$result[g4];
$g5=$result[g5];
$g6=$result[g6];
$g7=$result[g7];
$g8=$result[g8];
$g9=$result[g9];
$g10=$result[g10];
$g11=$result[g11];
$g12=$result[g12];
$g13=$result[g13];
$g14=$result[g14];
$g15=$result[g15];
$ex=$result[ex];
?>
<br>
<table width="550" height="105" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="15" bgcolor="#FFFFFF">
<div align="center"></div></td>
</tr>
<tr>
<td height="30" bgcolor="#FFFFFF">
<div align="center"></div></td>
</tr>
<tr>
<td height="30" bgcolor="#FFFFFF">
<div align="center"><font size="3" face="Tahoma"><strong><font color="#000000">รหัสนักศึกษา&nbsp;:</font><font color="#0000FF">
<?echo"$code";?></font></strong></font> <font color="#0000FF"><strong><font size="3" face="Tahoma">&nbsp;&nbsp;&nbsp;<font color="#000000">ชื่อ</font>
<?echo"$name";?>&nbsp;&nbsp;<font color="#000000">นามสกุล</font> &nbsp;<?echo"$sername";?></font>
</strong></font> </div></td>
</tr>
</table>
<table width="550" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="360">
<table width="350" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000099">
<tr>
<td> <table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr bgcolor="#FFFFFF">
<td width="53%" height="25"><div align="center"><strong><font size="3" face="Tahoma">ชื่อรายวิชา</font></strong></div></td>
<td height="25"><div align="center"><strong><font size="3" face="Tahoma">ผลการสอบ</font></strong></div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" valign="baseline" nowrap><font size="3" face="Tahoma">วิชากฎหมาย
:</font></td>
<td width="47%" height="25"><strong><font size="3" face="Tahoma"><?echo"$g1";?>
</font></strong><font size="3" face="Tahoma">คะแนน <font color="#0000FF">เต็ม
50</font></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" valign="baseline" nowrap><font size="3" face="Tahoma">วิชาศัพท์แพทย์
:</font></td>
<td height="25"><strong><font size="3" face="Tahoma"><?echo"$g2";?>
</font></strong><font size="3" face="Tahoma">คะแนน <font color="#0000FF">เต็ม
50</font></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" valign="baseline" nowrap><font size="3" face="Tahoma">วิชาการดูแลเด็ก
:</font></td>
<td height="25"><strong><font size="3" face="Tahoma"><?echo"$g3";?>
</font></strong><font size="3" face="Tahoma">คะแนน <font color="#0000FF">เต็ม
50</font></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" valign="baseline" nowrap><font size="3" face="Tahoma">วิชาพัฒนาบุคลิกภาพ
:</font></td>
<td height="25"><strong><font size="3" face="Tahoma"><?echo"$g4";?>
</font></strong><font size="3" face="Tahoma">คะแนน <font color="#0000FF">เต็ม
40</font></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" valign="baseline" nowrap><font size="3" face="Tahoma">วิชาภาษาจีนกลาง
:</font></td>
<td height="25"><strong><font size="3" face="Tahoma"><?echo"$g5";?>
</font></strong><font size="3" face="Tahoma">คะแนน <font color="#0000FF">เต็ม
50</font></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" valign="baseline" nowrap><font size="3" face="Tahoma">วิชานันทนาการ
:</font></td>
<td height="25"><strong><font size="3" face="Tahoma"><?echo"$g6";?>
</font></strong><font size="3" face="Tahoma">คะแนน <font color="#0000FF">เต็ม
50</font></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" valign="baseline" nowrap><font size="3" face="Tahoma">วิชาโภชนาการ
:</font></td>
<td height="25"><strong><font size="3" face="Tahoma"><?echo"$g7";?>
</font></strong><font size="3" face="Tahoma">คะแนน <font color="#0000FF">เต็ม
50</font></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" valign="baseline" nowrap><font size="3" face="Tahoma">วิชาระบบปัสสาวะ
:</font></td>
<td height="25"><strong><font size="3" face="Tahoma"><?echo"$g8";?>
</font></strong><font size="3" face="Tahoma">คะแนน <font color="#0000FF">เต็ม
15</font></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" valign="baseline" nowrap><font size="3" face="Tahoma">วิชายาสามัญ
:</font></td>
<td height="25"><strong><font size="3" face="Tahoma"><?echo"$g9";?>
</font></strong><font size="3" face="Tahoma">คะแนน <font color="#0000FF">เต็ม
30</font></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" valign="baseline" nowrap><font size="3" face="Tahoma">วิชายาสมุนไพร
:</font></td>
<td height="25"><strong><font size="3" face="Tahoma"><?echo"$g10";?>
</font></strong><font size="3" face="Tahoma">คะแนน <font color="#0000FF">เต็ม
30</font></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" valign="baseline" nowrap><font size="3" face="Tahoma">วิชาการพยาบาล
:</font></td>
<td height="25"><strong><font size="3" face="Tahoma"><?echo"$g11";?>
</font></strong><font size="3" face="Tahoma">คะแนน <font color="#0000FF">เต็ม
30</font></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" valign="baseline" nowrap><font size="3" face="Tahoma">การพยาบาล
:</font></td>
<td height="25"><strong><font size="3" face="Tahoma"><?echo"$g12";?>
</font></strong><font size="3" face="Tahoma">คะแนน <font color="#0000FF">เต็ม
30</font></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" valign="baseline" nowrap><font size="3" face="Tahoma">การพยาบาล
:</font></td>
<td height="25"><strong><font size="3" face="Tahoma"><?echo"$g13";?>
</font></strong><font size="3" face="Tahoma">คะแนน <font color="#0000FF">เต็ม
10 </font></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" valign="baseline" nowrap><font size="3" face="Tahoma">กายวิภาคศาสตร์
:</font></td>
<td height="25"><strong><font size="3" face="Tahoma"><?echo"$g14";?>
</font></strong><font size="3" face="Tahoma">คะแนน <font color="#0000FF">เต็ม
30</font></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" valign="baseline" nowrap><font size="3" face="Tahoma">กายวิภาคศาสตร์
:</font></td>
<td height="25"><strong><font size="3" face="Tahoma"><?echo"$g15";?>
</font></strong><font size="3" face="Tahoma">คะแนน <font color="#0000FF">เต็ม
10</font></font></td>
</tr>
</table></td>
</tr>
</table>
</td>
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center"><strong><em><font color="#FF0000" size="3" face="Tahoma">หมายเหตุ</font></em></strong></div></td>
</tr>
<tr>
<td bgcolor="#FF0000"><table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td height="351" valign="top" bgcolor="#FFFFFF"><strong><font size="3" face="Tahoma"><?echo"$ex";?>
</font></strong></td>
</tr>
</table></td>
</tr>
</table>
<div align="center"><a href="#"onClick="window.close()"><br>
<img src="../button/close1.jpg" alt="ยกเลิก" width="69" height="20" border="0" align="absmiddle"></a>
<strong><font size="3" face="Tahoma">
<input type="submit" name="Submit22" value="Print" onClick="window.print()">
</font></strong> </div></td>
</tr>
</table>
<?
$a++;
}
}

}
?>
</body>
</html>



<body>

</body>
</html>



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 23 ก.ย. 2550 22:45:54 By : หน่อย View : 1393 Reply : 2
 

 

No. 1

Guest


ใส่ตอบโชว์ก็ได้นะครับ

ก่อนอี่นก็ต้องทำการ check ก่อนครับ
if ($score>=50) {
$f_color = "#0000CC";
} else {
$f_color = "#FF0000";
}

เวลาโชว์ก็ใช้เป็น
<font color=<?=$f_color?>><?=$score?></font>






Date : 24 ก.ย. 2550 00:04:20 By : mr-know.com
 


 

No. 2

Guest


ขอบคุณค่ะ คุณmr-know.com


ก่อนอี่นก็ต้องทำการ check ก่อนครับ
ตัวนี้ต้องเอาไว้ส่วนไหนค่ะ

if ($score>=50) {
$f_color = "#0000CC";
} else {
$f_color = "#FF0000";
}



เวลาโชว์ก็ใช้เป็น
<font color=<?=$f_color?>><?=$score?></font>



Date : 24 ก.ย. 2550 09:01:39 By : หน่อย
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยด้วยค่ะ เรื่องการดึงข้อมูลมาแสดงแล้วให้เปลี่ยนสี ค่ะ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่