|
|
|
ช่วยตรวจสอบโค้ดให้หน่อยค่ะว่าทำไมข้อมูลในตารางถึงไม่ขึ้น ในตัวโค้ดนั้นได้ทำการ JOIN TABLE ไว้ด้วยเพราะต้องการให้ข้อมูลของทั้ง 2 ตารางโชว์ข้อมูลขึ้นมา แต่ปรากฎว่าข้อมูลไม่ขึ้น |
|
|
|
|
|
|
|
ช่วยตรวจสอบโค้ดให้หน่อยค่ะว่าทำไมข้อมูลในตารางถึงไม่ขึ้น ในตัวโค้ดนั้นได้ทำการ JOIN TABLE ไว้ด้วยเพราะต้องการให้ข้อมูลของทั้ง 2 ตารางโชว์ข้อมูลขึ้นมา แต่ปรากฎว่าข้อมูลไม่ขึ้น
ตาราง Score
ตาราง Student
โค้ดหน้ารายงานผลการสอบ
Code (PHP)
<?php
require_once('../Connections/MyConnec.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "index.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows = 14;
$pageNum = 0;
if (isset($_GET['pageNum'])) {
$pageNum = $_GET['pageNum'];
}
$startRow = $pageNum * $maxRows;
mysql_select_db($database_MyConnec, $MyConnec);
$query ="select student.St_id,student.St_User,student.St_name,student.St_surname,score.St_score,score.St_sta
from student
inner join score on student.St_User=score.St_id";
$query_limit = sprintf("%s LIMIT %d, %d", $query, $startRow, $maxRows);
$data = mysql_query($query_limit,$MyConnec)or die(mysql_error());
$row = mysql_fetch_assoc($data);
if (isset($_GET['totalRows'])) {
$totalRows = $_GET['totalRows'];
} else {
$all = mysql_query($query);
$totalRows = mysql_num_rows($all);
}
$totalPages = ceil($totalRows/$maxRows)-1;
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ออกรายงาน</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" >Student</a>
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="Teacher_page.php">Home</a></li>
<li><a href="test_Management.php">จัดการข้อสอบ</a></li>
<li><a href="Student_Information.php">ข้อมูลนักศึกษา</a></li>
<li><a href="report_Tc.php">ออกรายงาน</a></li>
<li><a href="index.php">LOGOUT</a></li>
</ul>
</div>
</nav>
<form>
<center>
<h2> รายงานคะแนนนักศึกษา</h2>
<br>
<p> </p>
<form id="form1" name="form1" method="post" action="search_report.php">
<center> ค้นหา :
<input type="text" name="word" id="word" />
<input type="submit" name="btnSearch" id="btnSearch" value="ค้นหา" />
</form>
<p> </p>
<?
mysql_close();
?>
<table class="table table-condensed">
<thead>
<tr>
<th>ลำดับ</th>
<th>รหัสนักศึกษา</th>
<th>ชื่อ</th>
<th>นามสกุล</th>
<th>คะแนน</th>
<th>สถานะ</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysql_fetch_assoc($data)){ //loop เพื่อให้ตารางในฐานข้อมูลขึ้นทั้งหมด
?>
<tr>
<td><?php echo $row['St_id']; ?></td>
<td><?php echo $row['St_User']; ?></td>
<td><?php echo $row['St_name']; ?></td>
<td><?php echo $row['St_surname']; ?></td>
<td><?php echo $row['St_score']; ?></td>
<td><?php echo $row['St_sta']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<?
include "connect.php";
$no=1;
if ($_POST['keyword']!=""){
$Qtotal =mysql_query("select * from product ");
$totalnum = mysql_num_rows($Qtotal);
$rs = mysql_query("select * from product where ($cate like '%{$_POST['keyword']}%' ) ");
}else {
$rs= mysql_query("select *from product ORDER BY ID_Pro ASC");
}
while ($a=mysql_fetch_array($rs)){
?>
<tr>
<td height="60" colspan="4" align="center">
<p style="margin:0 auto; text-align:center; width:550px;">
<SCRIPT LANGUAGE="JavaScript">
if (window.print) {
document.write('<input type=button name=print value="พิมพ์หน้านี้" '
+ 'onClick="javascript:window.print()">');
}
</script>
</td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
รูปแสดงผล
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2017-03-30 16:26:01 |
By :
Tarnikar |
View :
1559 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอโทษค่ะ ลงโค้ดผิด ที่จริงต้องโค้ดอันนี้ค่ะ
Code (PHP)
<?php
require_once('../Connections/MyConnec.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
?>
<?php
mysql_select_db($database_MyConnec, $MyConnec);
$query ="select subject.Sub_id,subject.Sub_name,score.St_id,score.St_score,score.St_sta,score.St_User,score.Sub_id
from subject
inner join score on subject.Sub_id=score.Sub_id";
$data = mysql_query($query,$MyConnec)or die(mysql_error());
$row = mysql_fetch_assoc($data);
$totalRows = mysql_num_rows($data);
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ออกรายงาน</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#"></a>
</div>
<ul class="nav navbar-nav">
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="index.php"><span class="glyphicon glyphicon-log-in"></span> LogOut</a></li>
</ul>
</div>
</nav>
<?php
$u=$_SESSION["User_name"];//มาจากcheck_login
//mysql_select_db($database_MyConnec, $MyConnec);
$sql="SELECT * FROM student WHERE St_user='".$u."'";
$qe=mysql_query($sql,$MyConnec);
//$query = mysql_query($sql, $MyConnec);// or die(mysql_error());
$data=mysql_fetch_array($qe);
//$row = mysql_fetch_assoc($query);
?>
<form>
<div class="container">
<h2>สรุปผลการสอบ</h2>
<center>คุณ : <?php echo $data["St_name"]." ".$data["St_surname"];?>
<br>
รหัสนักศึกษา : <?php echo $data["St_User"];?>
<br>
กลุ่มเรียน : <?php echo $data["St_Grop"];?>
<br>
คณะ : <?php echo $data["Fac_id"];?>
<br>
สาขา : <?php echo $data["Bra_id"];?>
</center> <br>
<table class="table table-condensed">
<thead>
<tr>
<th>ลำดับ</th>
<th>วิชา</th>
<th>คะแนน</th>
<th>สถานะ</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $row["Sub_id"];?></td>
<td><?php echo $row["Sub_name"];?></td>
<td><?php echo $row["St_score"];?></td>
<td><?php echo $row["St_sta"];?></td>
</tr>
</tbody>
</table>
</div>
</form>
</body>
ปล.เขียนเองแล้วค่ะแต่งง เลยทำในดรีมแทน
|
|
|
|
|
Date :
2017-03-30 18:08:44 |
By :
Tarnikar |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลอง เอา code SELECT ไปใส่ ใน phpMyAdmin ดูครับ ว่า รันได้ไหม
|
|
|
|
|
Date :
2017-04-05 15:54:35 |
By :
tamiiz01jr |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|