|
|
|
อยากได้เว็บบอร์ดที่มีหน้าตาคล้ายเว็บนี้ค่ะ. ..พอมีโค้ดไหมค่ะ. ..ที่ทำให้มีสีแต่ละบรรทัดสลับกันหนะคะ |
|
|
|
|
|
|
|
ถ้าหากมีโค้ดแบบนี้หนะค่ะ
Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<html>
<head>
</head>
<body>
<a href="NewQuestion.php">ตั้งกระทู้ใหม่</a>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("meafahlung");
$strSQL = "SELECT * FROM webboard ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 10; // 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 QuestionID DESC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table width="909" border="0">
<tr>
<th width="99"> <div align="center">รหัส</div></th>
<th width="458"> <div align="center">เรื่อง</div></th>
<th width="90"> <div align="center">โดย</div></th>
<th width="130"> <div align="center">ล่าสุด</div></th>
<th width="45"> <div align="center">View</div></th>
<th width="47"> <div align="center">Reply</div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?=$objResult["QuestionID"];?></div></td>
<td><a href="ViewWebboard.php?QuestionID=<?=$objResult["QuestionID"];?>"><?=$objResult["Question"];?></a></td>
<td><?=$objResult["Name"];?></td>
<td><div align="center"><?=$objResult["CreateDate"];?></div></td>
<td align="right"><?=$objResult["View"];?></td>
<td align="right"><?=$objResult["Reply"];?></td>
</tr>
<?
}
?>
</table>
<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);
?>
</body>
</html>
|
|
|
|
|
Date :
2012-11-14 20:00:55 |
By :
:( |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่เข้าใจค่ะ. ..ยังไงค่ะ
|
|
|
|
|
Date :
2012-11-14 20:07:09 |
By :
:( |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<html>
<head>
<style type="text/css">
tr:nth-child(odd)
{
background:#4863A0;
color:white;
}
tr:nth-child(even)
{
background:#38ACEC;
color:white;
}
</style>
</head>
<body>
<a href="NewQuestion.php">ตั้งกระทู้ใหม่</a>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("meafahlung");
$strSQL = "SELECT * FROM webboard ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 10; // 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 QuestionID DESC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table width="909" border="0">
<tr>
<th width="99"> <div align="center">รหัส</div></th>
<th width="458"> <div align="center">เรื่อง</div></th>
<th width="90"> <div align="center">โดย</div></th>
<th width="130"> <div align="center">ล่าสุด</div></th>
<th width="45"> <div align="center">View</div></th>
<th width="47"> <div align="center">Reply</div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?=$objResult["QuestionID"];?></div></td>
<td><a href="ViewWebboard.php?QuestionID=<?=$objResult["QuestionID"];?>"><?=$objResult["Question"];?></a></td>
<td><?=$objResult["Name"];?></td>
<td><div align="center"><?=$objResult["CreateDate"];?></div></td>
<td align="right"><?=$objResult["View"];?></td>
<td align="right"><?=$objResult["Reply"];?></td>
</tr>
<?
}
?>
</table>
<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);
?>
</body>
</html>
|
|
|
|
|
Date :
2012-11-15 00:10:41 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|