|  | 
	                
  
    | 
	 
        ผมจะทำหน้าแสดงผลการเรียนของนักศึกษาอะครับ ช่วยทีครับ ^^     |  
    |  |  
 
              
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | แล้วตอนนี้คุณออกแบบฐานข้อมูลไว้กี่ตารางอ่ะครับ บอกรายละเอียดนิดนึงจะได้ช่วยได้ตรงจุดครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-07-30 23:27:49 | By :
                            arm8957 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | (ตามความคิดผมนะ) ผมก็จะออกแบบฐานข้อมูลมี 2  ตาราง 
 student (std_id , std_name , teacher , subject , grad) //โดยที่ subject เป็น FK ซึ่งก็คือรหัสวิชาที่นักศึกษาลงทะเบียนเรียน
 subject ( sub_id , sub_name , cradit , std_regit) //โดยที่ std_regit เป็น FK ซึ่งก็คือรหัสนักศึกษาที่ลงทะเบียนเรียน
 
 ส่วนการดึงข้อมูลมาแสดงจะใช้การ join ครับ
 Code (PHP)
 
 <?PHP
$objQuery = mysql_query("SELECT student.std_id , student.std_name , student.teacher , student.grad , subject.sub_name FROM student LEFT JOIN subject ON student.std_id = subject.std_regit AND student.subject = subject.sub_id WHERE student.std_id ='".$_REQUEST['std_id']."'");
$result = mysql_fetch_array($objQuery);
?>
<table border=1>
ประวัติของ <?echo $result['std_id'];?><br>
<hr>
<tr>
<td>ชื่อ-นามสกกุล</td><td>อาจารย์ที่ปรึกษา</td><td>รายวิชาที่เรียน</td><td>ผลการเรียน</td>
</tr>
<tr>
<td><?echo $result['std_name']; ?></td>
<td><?echo $result['teacher']; ?></td>
<td><?echo $result['sub_name']; ?></td>
<td><?echo $result['grad']; ?></td>
</tr>
</table>
 ลองดูครับว่าได้ตามที่ต้องการป่าว
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-07-31 11:06:16 | By :
                            arm8957 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ที่ผมลองทำเองมั่วๆ ได้ออกมาแบบนี้อะครับ มันก็แสดง ชื่อของ id นักศึกษาที่ใส่ไปแล้วก็แสดงรายวิชาของ ปีนั้นๆที่ลงทะเบียนไว้ละครับ เหลือแต่เกรด Code (PHP)
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->
<head>
<title>แสดงข้อมูลนักศึกษา</title>
<meta http-equiv="Content-Language" content="th"> 
<meta http-equiv="content-Type" content="text/html; charset=window-874"> 
<meta http-equiv="content-Type" content="text/html; charset=tis-620"> 
</head>
<td height="156" class="bodyText"><p align="center" class="style17">
<? include ("connect.php");
$Sql = "select * from pvc1_1 where sid='".$_REQUEST['sid']."'";
$Result = mysql_query($Sql);  //คำสั่งการกระทำคิวรี่
//เซทตัวหนังสือเป็นภาษาไทย
$cs1 = "SET character_set_results=tis620";
mysql_query($cs1) or die('Error query: ' . mysql_error()); 
$cs2 = "SET character_set_client = tis620";
mysql_query($cs2) or die('Error query: ' . mysql_error()); 
$cs3 = "SET character_set_connection = tis620";
mysql_query($cs3) or die('Error query: ' . mysql_error());
?>
<table border=1>
ประวัติของ <?echo $_REQUEST['sid'];?><br>
<hr>
<tr>
<td>ชื่อ-นามสกกุล</td><td>อาจารย์ที่ปรึกษา</td>
</tr>
<?
$Row = mysql_fetch_array($Result);
?>
<tr>
<td><?echo $Row['sname']; ?></td>
<td><?echo $Row['steach']; ?></td>
</tr>
</table>
<hr>
<CENTER><td height="156" class="bodyText"><p align="center" class="style17">
<? include ("connect.php");
$Sql2 ='SELECT * FROM `timetablepvc1_1_2` LIMIT 0, 30 '; 
$Result2 = mysql_query($Sql2);  //คำสั่งการกระทำคิวรี่
?>
<table width="50%" border="1"  align="center">
<CENTER>ผลการเรียนของ <?echo $_REQUEST['sid'];?> เทอมที่ 1<br></CENTER>
<hr>
<tr>
<td width=" 7%"><div align="center">รหัสวิชา</td>
<td width=" 15%"><div align="center">ฃื่อวิชา</td>
<td width=" 4%"><div align="center">หน่วยกิต</td>
<td width=" 4%"><div align="center">เกรด</td>
</tr>
<?
while ($Row2 = mysql_fetch_array($Result2)) {
?>
<tr>
<td><?echo $Row2['subid']?> </td>
<td><?echo $Row2['subname']?></td>
<td><?echo $Row2['subunit']?></td>
</tr>
<?
}
?>
</table></CENTER>
<p align="center">ดูเวลาเรียนนักศึกษา</p>
<p align="center"><a href="../timetable/TBPVC1-1-2.html" target="_blank">ดูตารางสอน</a></p>
<p><a href=selectidpvc1-1.html>Back</a><br>
<br>
</body>
</html>
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-07-31 14:25:11 | By :
                            nnewmoon |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | แล้วตอนนี้คุณเก็บเกรดไว้ในตารางไหนหรอครับ? 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-07-31 14:45:15 | By :
                            arm8957 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ก็ผมแนะนำไปแล้วไงครับ ตาม "ความคิดเ้ห็นที่ 3 " อ่ะครับ ใช้ได้ไม๊ แต่การออกแบบฐานข้อมูลมันก็ขึ้นอยู่กับว่าแต่ละคนคิดยังไงนะครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-07-31 15:40:33 | By :
                            arm8957 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | อ่อครับผม ขอบคุณมากครับ จะเอาไว้เป็นแนวทางครับ 
 อยากให้อธิบายส่วนนี้แบบละเอียดหน่อยอะครับผมอยากทราบ
 
 Code (PHP)
 
 <?PHP 
02.$objQuery = mysql_query("SELECT student.std_id , student.std_name , student.teacher , student.grad , subject.sub_name FROM student LEFT JOIN subject ON student.std_id = subject.std_regit AND student.subject = subject.sub_id WHERE student.std_id ='".$_REQUEST['std_id']."'"); 
03.$result = mysql_fetch_array($objQuery); 
04.?> 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-07-31 16:17:17 | By :
                            nnewmoon |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              |  
 เนี้ยครับที่ผมทำได้แล้ว แต่ไม่รู้จะเอาเกรดไว้ส่วนไหนให้มันแสดงออกมาทุกรายวิชาของแต่ละคนอะครับ ช่วยทำเพิ่มเติมจาก code ความคิดเห็นที่ 4 พอจะได้มั้ยครับ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-07-31 19:51:31 | By :
                            nnewmoon |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ขอดูฐานข้อมูลของคุณได้ไม๊ครับ เอาแบบว่าทุกฟิลด์เลยอ่ะครับ เอามาแต่ตารางที่เกี่ยวข้องอ่ะครับ แล้วจะเพิ่มให้ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-07-31 22:34:15 | By :
                            arm8957 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | นี้อะครับ ตารางของผม จะเอาเกรดไว้ไหนดีแล้วจะเอาของแต่ละคนมาแสดงยังไง
 เพราะว่าใส่หรัสคนไหนไปก็ต้องเอาของคนนั้นมาแสดงแบบ code ที่ผมโพสไว้ข้างต้นอะครับ
 
  
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-08-01 18:20:20 | By :
                            nnewmoon |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ขออีกคำถามครับ 
 ในตารางผมมีข้อมูลแบบนี้อะครับ
 
  
 แต่พอแสดงข้อมูลออกมาเป็นแบบนี้ ผมต้องการแสดง ข้อมูลในตารางถัดไปอะครับ แบบไม่วนลูบแสดงอะครับ ต้องการกำหนดเองอะครับ จะต้องใส่ยังไงครับในส่วนของ php แสดงผม
 
 
  
 Code (PHP)
 
 <tr>
<td><?echo $Row2['subid']?> </td>
<td><?echo $Row2['subname']?></td>
<td><?echo $Row2['subunit']?></td>
<td><?echo $Row['pvc1_1_1']?></td>
</tr>
<tr>
<td><?echo $Row2['subid']?> </td>
<td><?echo $Row2['subname']?></td>
<td><?echo $Row2['subunit']?></td>
<td><?echo $Row['pvc1_1_2']?></td>
</tr>
<tr>
<td><?echo $Row2['subid']?> </td>
<td><?echo $Row2['subname']?></td>
<td><?echo $Row2['subunit']?></td>
<td><?echo $Row['pvc1_1_3']?></td>
</tr>
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-08-01 18:20:52 | By :
                            nnewmoon |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ถ้าไม่ต้องการให้วน loop คุณก็ query ออกมาแต่ละตัวเลยครับ แบบกำหนด WHERE เอาเลย 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-08-01 18:45:26 | By :
                            arm8957 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ช่วยทีครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-08-17 11:01:23 | By :
                            New |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code (PHP) 
 <html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>
<body>
<div align="center">
  	<?
	include ("Connectdb.php");
	$strSQL = "SELECT * FROM  studentroom WHERE studentid ='3008'  GROUP by classyear ASC ,classsem ASC";
	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
	?>	
		<? 
        while($objResult = mysql_fetch_array($objQuery))
        {
        echo $chk_title = $objResult["classyear"];
        echo $chk_title2 = $objResult["classsem"];
        echo $chk_title3 = $objResult["studentid"];
        ?>
<div align="center"><table width="603" border="1">
    	<tr>
	    <td width="87"><div align="center">ปีการศึกษา</div></td>
		<td width="87"><div align="center">
        <? echo $objResult["classsem"];?>/
		<? echo $objResult["classyear"];?>
        </div></td>
	  	</tr>
			<? 
            include ("Connectdb.php");
            $strSQL2 = "SELECT * FROM regist  where   
            classyear= '$chk_title' AND classsem = '$chk_title2' AND studentid ='$chk_title3'";
            $objQuery2 = mysql_query($strSQL2) or die ("Error Query [".$strSQL2."]");
            while($objResult2 = mysql_fetch_array($objQuery2))
            {
            ?>
		 <tr>
		<td width="87"><div align="center"><? echo $objResult2["subjectid"];?></div></td>
        <td width="87"><div align="center"><? echo $objResult2["score"];?></div></td>
	  </tr>
	  		<? }?>
    
	<?
    mysql_close($objConnect);
    }
    ?>
  </p>
</div>
</body>
</html>
 ลองเอาไปศึกษาดูผมเพิ่งมั่วเสร็จไม่รู้ถูกป่าว
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2014-02-12 04:44:31 | By :
                            manongzaa |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |