|
 |
|
การเลือกโชว์ข้อมูลเฉพาะภาษาใดภาษานึงเราต้องมีการเขียนค่าดักโค๊ดอย่างไรบ้างครับ |
|
 |
|
|
 |
 |
|
ต่อครับนี่คือโค๊ดหน้าแรกที่ผมสาดไว้ครับ แต่ลืมไปว่าถ้ามีสองภาษาจะทำได้ไหมครับ T_T
Code (PHP)
<div id="container">
<div id="top"><img src="images/logo.jpg" width="750" height="98" /></div>
<div id="navcontainer">
</div>
<div id="leftnav">
<h2>Search Blog</h2>
<form name="frmSearch" method="get" action="viewblogs3.php" onSubmit="JavaScript:return fncSubmit();">
<p>
<input name="txtKeyword" type="text" id="txtKeyword" class="search" />
<input type="submit" value="Search" class="searchSubmit" />
</p>
</form>
<ul style="list-style-type: none;">
<h2><a href="index.php">Blog</a></h2>
<?php
//$numid=อันนี้เรียกมาจากหน้า Connect.inc.php เพื่อกำหนด ID อย่าลืมเช็คถ้ามีการตั้งบลอคIDใหม่//
$rs=mysql_query('select * from tb_k2_categories where tb_k2_categories.id='.$numid);
while( $ro=mysql_fetch_assoc($rs)){
//แสดง mainmenu
//echo "<li><b>$ro[name]</b><br>";
$rs2=mysql_query('select * from tb_k2_categories where tb_k2_categories.parent='.$ro['id']);
while( $ro2=mysql_fetch_assoc($rs2)){
// แสดงส่วนของsubmenu
//echo "<li>$ro2[name] </li>"; ?>
<a href="viewblogs2.php?ID=<?=$ro2["id"];?>" class="readmore"><?=$ro2["name"];?></a><br>
<?php
}
}
?>
</ul>
<?php
$strSQL = "SELECT
tb_k2_categories.id,tb_k2_items.id,tb_k2_categories.parent, tb_k2_items.catid, tb_k2_items.title, tb_k2_items.introtext,tb_k2_items.created
FROM tb_k2_items left join tb_k2_categories ON tb_k2_items.catid = tb_k2_categories.id
WHERE tb_k2_categories.parent = ".$numid;
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
//echo $strSQL;
//exit;
?>
</ul>
</div>
<div id="content">
<h2>Welcome to <span style="color: #b29b35">TTD_KM </span>Blog</h2><br />
<?php $Per_Page = 3; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$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 tb_k2_items.id DESC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
while($objResult = mysql_fetch_array($objQuery))
{
?>
<?php
$str1 = $objResult["title"];
$str = $objResult["introtext"];
?>
<p><img class="imgleft" src="images/1.png" alt="" /><h2><?php echo mb_substr($str1,0,50,'UTF-8');?>...</h2> <br />
<?php echo mb_substr($str,0,220,'UTF-8');?> .....
</p>
<?php
//echo $objResult["id"];
//exit;
?>
<p class="post"> <a href="viewblogs.php?ID=<?=$objResult["id"];?>" class="readmore">Read more</a><span class="date"><?=$objResult["created"];?></span></p><br />
<?
}
?>
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
mysql_close($objConnect);
?>
</div>
|
 |
 |
 |
 |
Date :
2014-12-11 10:29:07 |
By :
sarut14 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|