|
|
|
รบกวนช่วยแก้ไขโค้ดให้หน่อยค่ะ คือว่าหนูดึงข้อมูลมาโชว์ที่ตาราง data table กำหนดให้แสดงแค่ 10 แถวแต่ข้อมูลโชว์ทั้งหมด |
|
|
|
|
|
|
|
คือว่าหนูดึงข้อมูลมาโชว์ที่ตาราง data table กำหนดให้แสดงแค่ 10 แถวแต่ข้อมูลมันโชว์ทั้งหมดที่มีในดาต้าเบสเลยคะ
Code (PHP)
<?php
session_start();
include('check_member.php');
mysql_connect("localhost","root","03112530");
mysql_select_db("mydatabase");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
$strSQL = "SELECT * FROM tb_member WHERE m_id = '".$_SESSION['m_id']."' ";
$objQuery = mysql_query($strSQL);
$objResult10 = mysql_fetch_array($objQuery);
?>
<?php require_once('Connections/connectdb.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_connectdb, $connectdb);
$query_showproduct = "SELECT * FROM articles, articles_type WHERE articles.a_type_id = articles_type.a_type_id ORDER BY datesave DESC";
$showproduct = mysql_query($query_showproduct, $connectdb) or die(mysql_error());
$row_showproduct = mysql_fetch_assoc($showproduct);
$totalRows_showproduct = mysql_num_rows($showproduct);
$query_showproduct = "SELECT * FROM articles, articles_type WHERE articles.a_type_id = articles_type.a_type_id ORDER BY a_id DESC";
$showproduct = mysql_query($query_showproduct, $connectdb) or die(mysql_error());
$row_showproduct = mysql_fetch_assoc($showproduct);
$totalRows_showproduct = mysql_num_rows($showproduct);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>SYSTEM ADMIN</title>
<!-- Bootstrap Core CSS -->
<link href="../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- MetisMenu CSS -->
<link href="../vendor/metisMenu/metisMenu.min.css" rel="stylesheet">
<!-- DataTables CSS -->
<link href="../vendor/datatables-plugins/dataTables.bootstrap.css" rel="stylesheet">
<!-- DataTables Responsive CSS -->
<link href="../vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="../dist/css/sb-admin-2.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="../vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Articles Data</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
DataTables Advanced Tables
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead align="center">
<tr>
<th width="">ลำดับ</th>
<th width="">ประเภทข่าว</th>
<th width="">หัวข้อ</th>
<th width="">รายละเอียด</th>
<th width="">รูป 1</th>
<th width="">รูป 2</th>
<th width="">รูป 3</th>
<th width="">บันทึก</th>
<th width="">อัพเดท</th>
<th width="">แก้ไข</th>
</tr>
<?php do { ?>
</thead>
<tbody>
<tr class="odd gradeX">
<td align="center"><?php echo $row_showproduct['a_id']; ?></td>
<td align="center"><?php echo $row_showproduct['a_type_name']; ?></td>
<td> <?php echo $row_showproduct['title']; ?></td>
<td> <?php echo $row_showproduct['txtMessage']; ?></td>
<td> <img src="../../images/<?php echo $row_showproduct['img']; ?>" width="60" class="img img-responsive"></td>
<td> <img src="../../images/<?php echo $row_showproduct['img2']; ?>" width="60" class="img img-responsive"></td>
<td> <img src="../../images/<?php echo $row_showproduct['img3']; ?>" width="60" class="img img-responsive"></td>
<td> <?php echo $row_showproduct['m_name']; ?></td>
<td> <?php echo $row_showproduct['datesave']; ?></td>
<td align="center"><a href="form_edit_articles.php?a_id=<?php echo $row_showproduct['a_id']; ?>&do=edit">edit</a></td>
</tr>
<?php } while ($row_showproduct = mysql_fetch_assoc($showproduct)); ?>
</tbody>
</table>
<!-- /.table-responsive -->
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<!-- jQuery -->
<script src="../vendor/jquery/jquery.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="../vendor/bootstrap/js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="../vendor/metisMenu/metisMenu.min.js"></script>
<!-- DataTables JavaScript -->
<script src="../vendor/datatables/js/jquery.dataTables.min.js"></script>
<script src="../vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
<script src="../vendor/datatables-responsive/dataTables.responsive.js"></script>
<!-- Custom Theme JavaScript -->
<script src="../dist/js/sb-admin-2.js"></script>
<!-- Page-Level Demo Scripts - Tables - Use for reference -->
<script>
$(document).ready(function() {
$('#dataTables-example').DataTable({
responsive: true,
});
});
</script>
<?php
mysql_free_result($showproduct);
?>
</body>
</html>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2018-08-15 15:45:44 |
By :
panthipa |
View :
1680 |
Reply :
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หนูว่าหนูใช้คำถามผิด ตอนแรกคือ Limit แล้วคะแต่พอกดตัวแบ่งหน้าเหมือนมันไม่ทำงานคะ
|
|
|
|
|
Date :
2018-08-16 10:49:56 |
By :
panthipa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้าใช้ DataTable มันจะสร้างให้อัตโนมัติครับ
ตำแหน่งของ <?php do { ?> ผิดที่หรือเปล่า
|
|
|
|
|
Date :
2018-08-16 12:00:59 |
By :
apisitp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้ามันแบ่งหน้าให้แล้ว แต่กดไม่ทำงาน หนูก็ inspect ดูที่ tab console javascript มันเป็นไร สบายดีหรือเปล่า
|
|
|
|
|
Date :
2018-08-16 12:30:09 |
By :
DK |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอมูลเยอะไหม ถ้าเยอะ ใช้ datatable ไม่เหมาะ
ซัก 7-800 record ก็เริ่ม เอ๋อหน่อยๆ แล้ว กว่าจะเรนเดอร์เสร็จ
|
|
|
|
|
Date :
2018-08-16 15:41:24 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|