|
 |
|
php mysql สอบถามเรื่องปัญหาฐานข้อมูลมีปัญหากับภาษาไทยในการใช้ database ครับ |
|
 |
|
|
 |
 |
|
คือผมทำระบบทะเบียนครับ
จากหน้าเว็บที่ทำเป็นแบบนี้ครับ

ส่วนด้านล่างครับ

มัน error ช่วงนี้ครับ ไม่ทราบว่าเกียวกับปัญหาภาษไทยหรือเปล่า

คือผมอยากรู้ว่าจะแก้ปัญหาตรงนี้อย่างไรดีครับ
Code (PHP)
<?
# »ÃѺ»Ãا « 2550-05-20 (Version 1.0)
include("header.php");
include("config.php");
$connect = mysql_connect("$mysql_host","$mysql_user","$mysql_password");
if (isset($_GET["id"]) && strlen($_GET["id"]) > 0){
$sql = "SELECT regist.*,mainsubject.subjectid,mainsubject.classroom,mainsubject.no FROM
mainsubject LEFT JOIN regist ON mainsubject.subjectid = regist.subjectid
WHERE regist.studentid='".$_GET["id"]."' Or regist.studentid Is Null";
$result = mysql_db_query($mysql_db,$sql);
if ($result) echo "<table width=760 align=center bgcolor=#dddddd>"; else exit;
$i =0;
$oclass = "";
while ($object = mysql_fetch_object($result)) {
if ($i == 0) {
echo "<tr bgcolor=#dddddd><td colspan=4>
<b>ÃÒ§ҹáÊ´§¼ÅÃÇÁ¤Ðá¹¹ àÅ×Í¡µÒÁÃËÑʹѡàÃÕ¹ ᡵÒÁÃдѺªÑé¹</b><br>
$object->studentid ";
$sql = "select * from student where studentid ='".$_GET["id"]."'";
$rstudent = mysql_db_query($mysql_db,$sql);
if ($ostudent = mysql_fetch_object($rstudent)) echo "$ostudent->sfname $ostudent->slname ";
}
if ($oclass != $object->classroom) {
if ($i != 0) {
echo "<tr bgcolor=#dddddd><td colspan=4 align=right>ÃÇÁ¤Ðá¹¹: $tscore ¨Ó¹Ç¹ÇÔªÒ: $tsubject ¤Ðá¹¹à©ÅÕèÂ:" . substr($tscore / $tsubject,0,5);
$tscore = 0;
$tsubject = 0;
}
echo "<tr bgcolor=#ddffdd><td colspan=4>$object->classroom";
}
$tscore += $object->score;
if (strlen($object->score) > 0) $tsubject += 1;
$oclass = $object->classroom;
echo "<tr bgcolor=";
if ($i++ % 2 == 0) echo "#ffffdd>"; else echo "white>";
// echo "<td>$i";
// foreach($object as $o) echo "$o"; echo "<br>";
echo "<td>$object->no <td>$object->subjectid";
$sql = "select * from subject where subjectid ='".$object->subjectid."'";
$rsubject = mysql_db_query($mysql_db,$sql);
if ($osubject = mysql_fetch_object($rsubject)) echo " $osubject->subjectname";
echo "<td>$object->score";
echo "<td>$object->grade";
}
echo "<tr bgcolor=#dddddd><td colspan=4 align=right>ÃÇÁ¤Ðá¹¹: $tscore ¨Ó¹Ç¹ÇÔªÒ: $tsubject ¤Ðá¹¹à©ÅÕèÂ:" . substr($tscore / $tsubject,0,5);
echo "</table>Total records : ".mysql_num_rows($result);
}
include("footer.php");
?>
Tag : PHP, MySQL, CakePHP

|
|
 |
 |
 |
 |
Date :
2012-08-24 18:09:38 |
By :
jumloon2005 |
View :
928 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมได้แก้ไข้ตามที่คุณ mr.win
บอกล้วดังนี้ครับ

แล้วใส่นใน code ตามนี้ครับ
Code (PHP)
<html>
<head>
<title> PHP & UTF-8</title>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
</head>
<body>
<?
# »ÃѺ»Ãا « 2550-05-20 (Version 1.0)
include("header.php");
include("config.php");
$connect = mysql_connect("$mysql_host","$mysql_user","$mysql_password");
if (isset($_GET["id"]) && strlen($_GET["id"]) > 0){
$sql = "SELECT mainsubject.no, mainsubject.classroom, mainsubject.subjectid, subject.subjectname, student.sfname, regist.studentid, regist.grade
FROM (student RIGHT JOIN regist ON student.studentid = regist.studentid) RIGHT JOIN (mainsubject INNER JOIN subject ON mainsubject.subjectid = subject.subjectid) ON regist.subjectid = subject.subjectid
WHERE (((regist.studentid)='".$_GET["id"]."' Or (regist.studentid) Is Null))
ORDER BY mainsubject.no + 0";
$result = mysql_db_query($mysql_db,$sql);
if ($result) echo "<table width=760 align=center bgcolor=#dddddd>"; else exit;
$i =0;
$oclass = "";
while ($object = mysql_fetch_object($result)) {
if ($i == 0) {
echo "<tr bgcolor=#dddddd><td colspan=4>
<b>áÊ´§¼Å¡ÒÃàÃÕ¹¢Í§¹Ñ¡àÃÕ¹ àÅ×Í¡µÒÁÃËÑʹѡàÃÕ¹ ᡵÒÁÃдѺªÑé¹</b><br>
$object->studentid $object->sfname $object->slname";
}
if ($oclass != $object->classroom) echo "<tr bgcolor=#ddffdd><td colspan=4>$object->classroom";
$oclass = $object->classroom;
echo "<tr bgcolor=";
if ($i++ % 2 == 0) echo "#ffffdd>"; else echo "white>";
// echo "<td>$i";
// foreach($object as $o) echo "$o"; echo "<br>";
echo "<td>$object->no <td>$object->subjectid";
echo "<td>$object->subjectname <td>$object->grade";
}
echo "</table>Total records : ".mysql_num_rows($result);
}
include("footer.php");
?>
</body>
</html>
ผลการรันยังเป็นแบบนี้อยุ่ครับ

ช่วยหน่อยครับ
|
ประวัติการแก้ไข 2012-08-25 19:59:18
 |
 |
 |
 |
Date :
2012-08-25 19:57:00 |
By :
jumloon2005 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเพิ่ม mysql_db_query($dbname,"SET NAMES utf8"); หลังจาก connect ดูครับ
|
 |
 |
 |
 |
Date :
2012-08-28 17:48:39 |
By :
beembc |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|