|
|
|
โค้ดแบ่งหน้าค่ะ error และก็อยากให้ บรรทัดที่แบ่งมาอยู่ข้างบน มุมขวา ด้วย ต้องทำไงคะ |
|
|
|
|
|
|
|
question.php
Code (PHP)
<? include "include/config.php";?>
<? include "function/function_member.php";?>
<? include "function/function_webboard.php";?>
<? include "function/function_question.php";?>
<? include "function/page_func.inc.php";
?>
<!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" />
<link rel='stylesheet' type='text/css' href='css/indexStyle.css' media='all' />
<title>Untitled Document</title>
<style type="text/css">
<!--
a:link {
color: #FFCC00;
}
-->
</style></head>
<body>
<div id="topBarDiv"></div>
<div id="wrapperDiv">
<!-- start header-->
<div id="headerDiv">
</div> <!--end headerDiv-->
<!--end header-->
<!--start menu and search-->
<div id="menuDiv">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="menuTable">
<tr>
<td class="menu">
<? include "menu.php";?>
</td>
</tr>
</table>
</div> <!--end menuDiv-->
<!--end menu and search-->
<!--start top content-->
<div id="wrapperTopContentDiv">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="100">
</td>
<td valign="top">
<div id="readNewsRightContentDiv">
<p class="pReadNewsRightContentHeader">ชื่อห้อง </p>
<p class="pReadNewsRightContentDate">..................................</p>
<br>
<div id="bodyContent">
<table width="738" border="0" cellpadding="5" cellspacing="0" class="tableQuestion">
<tr>
<td> </td>
<td><div align="center"><h3>
<? //if(isset($_SESSION["user"])){?>
<a href="question_add.php?question=<?=$question?>">เพิ่มคำถาม</a>
<? //}?>
</h3>
</div></td>
<td> </td>
</tr>
<tr>
<td width="470"><h3>คำถาม</h3></td>
<td width="128"><div align="center"><h3>ผู้ตั้ง</h3></div></td>
<td><div align="center"><h3>วันที่</h3></div></td>
</tr>
<?
$perpage=10;
if(!isset($page)){
$page=1;
}
list($result,$total)=question_view($question,$page,$perpage);
while($row=mysql_fetch_array($result)){
$date=split("-",$row["question_date"]);
?>
<tr >
<td ><a href="question_view.php?question=<?=$row["question_id"]?>" style="text-decoration:none; color:#003300;"><?=$row["question_topic"]?></a></td>
<td><div align="center"><?=$row["question_name"]?></div></td>
<td width="100"><div align="center"><?=$date[2]?>/<?=$date[1]?>/<?=$date[0]?></div></td>
</tr>
<? }?>
<tr>
<td colspan="3" align="right"> <?
if($total>1){
showPageQuestion($total,$page,$question);
}
?></td>
</tr>
</table>
</div>
</div>
<br><br>
</td>
</tr>
</table>
</div> <!--end wrapperTopContentDiv-->
<!-- end top content-->
<div id="footerDiv">
Copyright © 2001-2010 ivf All rights reserved. Telephone: 0108414736771, Fax: 025255544
</div>
</div><!-- end wrapperDiv-->
</body>
</html>
ผลลัพท์
question_view.php
<? include "include/config.php";?>
<? include "function/function_question.php";?>
<!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" />
<link rel='stylesheet' type='text/css' href='css/indexStyle.css' media='all' />
<title>Untitled Document</title>
</head>
<?
if($Submit!=null){
answer_insert($desc,$question,$name,$email);
}
?>
<body>
<div id="topBarDiv"></div>
<div id="wrapperDiv">
<!-- start header-->
<div id="headerDiv">
</div> <!--end headerDiv-->
<!--end header-->
<!--start menu and search-->
<div id="menuDiv">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="menuTable">
<tr>
<td class="menu">
<? include "menu.php";?>
</td>
</tr>
</table>
</div> <!--end menuDiv-->
<!--end menu and search-->
<!--start top content-->
<div id="wrapperTopContentDiv">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="50"> </td>
<td valign="top">
<?
$result=question_view_id($question);
$row=mysql_fetch_array($result);
$date=split("-",$row["question_date"]);
?>
<div id="readNewsRightContentDiv">
<p class="pReadNewsRightContentHeader"><?=$row["question_topic"]?></p>
<p class="pReadNewsRightContentDate">วันที่ <?=$date[2]?>/<?=$date[1]?>/<?=$date[0]?> ..................................</p>
<br>
<div id="bodyContent">
<?=$row["question_desc"]?>
</div>
</div>
<br><br>
<hr style="color:#003300; width:70%" />
<?
/// ---------------- เพิ่มมา --------------------->
$perpage=2;
if(!isset($page)){
$page=1;
}
list($result2,$total)=answer_view($question,$page,$perpage);
// ---------------- --------------------->
while($row2=mysql_fetch_array($result2)){
$date=split("-",$row2["answer_date"]);
?>
<div id="readNewsRightContentDiv">
<?=$row2["answer_desc"]?>
<br/><br>
<p class="pReadNewsRightContentDate" align="right">แสดงความคิดเห็น โดย <?=$row2["answer_name"]?></p>
<p class="pReadNewsRightContentDate" align="right">วันที่ <?=$date[2]?>/<?=$date[1]?>/<?=$date[0]?></p>
</div>
<hr style="color:#003300; width:70%" />
<?
}
?>
<!---------------- เพิ่มมา --------------------->
<div align="right" style="margin-right:20px">
<?
if($total>1){
showPageAnswer($total,$page,$question);
}
?>
</div>
<? //if(isset($_SESSION["user"])){?>
<div id="readNewsRightContentDiv">
<p class="pReadNewsRightContentHeader">แสดงความคิดเห็น</p>
<p class="pReadNewsRightContentDate"> ..................................</p>
<form action="" method="post">
<table width="600" border="0" cellpadding="5" cellspacing="6">
<tr>
<td width="118" valign="top"> </td>
<td width="466"><textarea name="desc" cols="50" rows="10"></textarea>
<input name="question" type="hidden" value="<?=$row["question_id"]?>" /></td>
</tr>
<tr>
<td>ชื่อ</td>
<td>
<input type="text" name="name" id="name" />
</td>
</tr>
<tr>
<td>อีเมล์</td>
<td><input type="text" name="email" id="email" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="แสดงความคิดเห็น" />
<input type="reset" name="Submit2" value="ยกเลิก" /></td>
</tr>
</table>
</form>
<p class="pReadNewsRightContentDate"> </p>
<br>
<div id="bodyContent"> </div>
</div>
<br><br>
<? //}?> </td>
</tr>
</table>
</div> <!--end wrapperTopContentDiv-->
<!-- end top content-->
<div id="footerDiv">
Copyright © 2001-2010 ivf All rights reserved. Telephone: 0108414736771, Fax: 025255544
</div>
</div><!-- end wrapperDiv-->
</body>
</html>
[font=Verdana]อยากให้โค้ดแบ่งหน้ามาอยู่ข้างบนมุมขวาของหน้าด้วย ต้องทำไงคะ และก็ error ด้วย แก้ตรงไหนคะ[/font]
Tag : PHP
|
|
|
|
|
|
Date :
2010-08-26 16:07:04 |
By :
mostgirls |
View :
1121 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function_question.php
Code (PHP)
<?
function question_insert($name,$desc,$name1,$email,$webboard){
$date=date("Y-m-d");
$sql="insert into question(question_topic,question_desc,question_date,question_name,question_email,webboard_id)";
$sql .="values('$name','$desc','$date','$name1','$email','$webboard')";
$result=mysql_query($sql);
return $result;
}
function question_view($webboard,$page,$perpage){
$sql="select *from question where webboard_id='$webboard' order by question_id desc";
$result=mysql_query($sql);
$nr=mysql_num_rows($result);
$totalpage = ceil($nr/$perpage);
$sql_limit = ($page - 1) * $perpage ;
$sql_limit = " LIMIT " . $sql_limit . ", " . $perpage . " ";
$sql .= $sql_limit ;
$result1=mysql_query($sql);
return array($result1,$totalpage);
}
function question_view_id($id){
$sql="select *from question where question_id='$id' ";
$result=mysql_query($sql);
return $result;
}
function question_view_index($webboard){
//$sql="select *from question where webboard_id='$webboard' order by question_id desc Limit 0,5";
$sql="SELECT question.question_id as question_id,question_topic,max(answer_id) as answer_max FROM question
LEFT JOIN answer ON question.question_id = answer.question_id where webboard_id='$webboard' Group BY question.question_id Order by answer_max desc Limit 0,10";
$result=mysql_query($sql);
return $result;
/*
SELECT question.question_id as question_id,question_topic,max(answer_id) as answer_max FROM question LEFT JOIN answer ON question.question_id = answer.question_id where webboard_id='1' group by question.question_id order by answer_max desc
*/
}
function answer_insert($desc,$question,$name,$email){
$date=date("Y-m-d");
$sql="insert into answer(answer_desc,answer_date,answer_name,answer_email,question_id)";
$sql .="values('$desc','$date','$name','$email','$question')";
$result=mysql_query($sql);
return $result;
}
function answer_view($question,$page,$perpage){
$sql="select *from answer question_id='$question' order by answer_id ASC";
$result=mysql_query($sql);
$nr=mysql_num_rows($result);
$totalpage = ceil($nr/$perpage);
$sql_limit = ($page - 1) * $perpage ;
$sql_limit = " LIMIT " . $sql_limit . ", " . $perpage . " ";
$sql .= $sql_limit ;
$result1=mysql_query($sql);
return array($result1,$totalpage);
}
?>
|
|
|
|
|
Date :
2010-08-26 16:09:02 |
By :
mostgirls |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำยังไม่ได้เลย
|
|
|
|
|
Date :
2010-08-27 15:09:27 |
By :
mostgirls |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|