|
 |
|
ดึงรูปภาพกับข้อมูลใน mysql แล้วมันเป็น ??????? อย่างนี้อะคับ |
|
 |
|
|
 |
 |
|
ผมคิดว่าตอนที่เรา inset ข้อมูลลงใน DB อ่ะครับ เราได้กำหนด encoding ไว้เป็นแบบไหนอ่ะครับ เป็น utf-8 หรือ tis-60 อ่ะครับ เพราะบางครั้ง DB มันจะอ่าน ข้อมูล ภาษาไทยเราไม่ออก ดังนั้น เราต้อง กำหนด ให้ DB encoding เป็น TH ด้วยน่ะครับ
เพราะดูจาก code sql แล้ว เป็นแค่การ fetch ข้อมูลขึ้นมา โชว์เท่านั้น
ปัญหานี้ อยู่ที่ ขั้นตอนในการ insert ข้อมูลลง DB ครับ ลองเช็คดู่นะครับ
|
 |
 |
 |
 |
Date :
2010-02-11 16:39:59 |
By :
sescii |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
mysql_query("set NAMES'UTF8'");/// เพิ่มบรรทัดนี้เข้าไปนะครับ
$objDB = mysql_select_db("test");
$strSQL = "SELECT * FROM `order` WHERE `id`";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 20; // จำนวน ที่แสดงต่อ page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;//เก็บผล ตัวแปล - 1 ไว้ที่ ตัวแปล $Parev_Page
$Next_Page = $Page+1;// เก็บผล ตัวแปล
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$strSQL .=" order by id_order ASC LIMIT $Page_Start , $Per_Page";//เรียก page ตาม id_order
$objQuery = mysql_query($strSQL);
?>
<table border="1">
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td rowspan="3" width="60" height="80"><div align="center"><?=$objResult["images"];?></div></td>
<td><div align="center"><?=$objResult["proname"];?></div></td>
</tr>
<tr>
<td><div align="center"><?=$objResult["idpro"];?></div></td>
</tr>
<tr>
<td><div align="center"><?=$objResult["price"];?></div></td>
</tr>
<?
}
?>
</table>
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page:</font>
<?
if($Prev_Page)
{
echo " <font color='#333333' size='2'><a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a></font> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "<font color='#333333' size='2'>[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]</font>";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <center><font color='blue'><a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a></font></center> ";
}
mysql_close($objConnect);
?>
</body>
</html>
|
 |
 |
 |
 |
Date :
2010-02-11 16:50:05 |
By :
SOUL |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองแล้วมันขึ้นอย่างนี้อะคับ อันบน
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\pages1.php on line 42
ยังไงดี ???
|
 |
 |
 |
 |
Date :
2010-02-11 20:38:28 |
By :
adunafah |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|