|
|
|
ติด Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource ครับช่วยผมที T-T |
|
|
|
|
|
|
|
มันขึ้น Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\mkotu\showsettingmko.php on line 53
Code (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=windows-874" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<?php
include("dbconn.inc.php");
include("paging.inc.php");
?>
<table width="1200" border="0" align="center" cellpadding="7" cellspacing="1">
<tr>
<th width=100>ชื่อมหาวิทยาลัย(ไทย)</th>
<th width=100>ชื่อมหาวิทยาลัย(อังกฤษ)</th>
<th width=100>ชื่อคณะ(ไทย)</th>
<th width=100>ชื่อคณะ(อังกฤษ)</th>
<th width=100>สาขา(ไทย)</th>
<th width=100>สาขา(อังกฤษ)</th>
<th width=100>ชื่อหลักสูตร(ไทย)</th>
<th width=100>ชื่อหลักสูตร(อังกฤษ)</th>
<th width=100>ชื่อย่อหลักสูตร(ไทย)</th>
<th width=100>ชื่อย่อหลักสูตร(อังกฤษ)</th>
<th width=100>หน่วยกิตตลอดหลักสูตร</th>
</tr>
<?php
$current_page = 1;
if(isset($_GET['page'])) {
$current_page = $_GET['page'];
}
$rows_per_page = 20;
$start_row = paging_start_row($current_page, $rows_per_page);
//อ่านข้อมูลจากตารางโดยเรียงลำดับจากกระทู้ล่าสุดไปยังกระทู้ก่อนหน้านี้
$sql = " SELECT SQL_CALC_FOUND_ROWS *,
FROM university
ORDER BY universityNo DESC
LIMIT $start_row, $rows_per_page;";
echo $sql;
$result = mysql_query($sql);
$found_rows = mysql_query("SELECT FOUND_ROWS();");
$total_rows = mysql_result($found_rows, 0, 0);
$total_pages = paging_total_pages($total_rows, $rows_per_page);
//สีพื้นหลังสำำหรับการสลับสีระหว่างแถว
$bgcolor1 = "#eeeeff";
$bgcolor2 = "#ddeeff";
$bgcolor = $bgcolor1;
while($data = mysql_fetch_array($result)) {
$bgcolor = ($bgcolor == $bgcolor1) ? $bgcolor2 : $bgcolor1;
//แต่ละหัวข้อกระทู้ จะทำเป็นลิงค์เชื่อมโยงไปยังเพจ reply.php
//เพื่อให้สามารถคลิกเข้าไปดูรายละเอียดของกระทู้นั้นได้
//โดยแนบหมายเลข(id)ของกระทู้นั้นไปด้วย
echo "<tr bgcolor=$bgcolor valign=top>
<td>{$data['nameUniversityTh']}</td>
<td>{$data['nameUniversityEng']}</td>
<td>{$data['facultyTh']}</td>
<td>{$data['facultyEng']}</td>
<td>{$data['branchTh']}</td>
<td>{$data['branchEng']}</td>
<td>{$data['couseNameTh']}</td>
<td>{$data['couseNameEng']}</td>
<td>{$data['courseInitialTh']}</td>
<td>{$data['courseInitialEng']}</td>
<td>{$data['creditAllCourse']}</td>
</tr>";
}
//แสดงหมายเลขเพจ
echo "<tr> <td colspan=4 align=center>";
$page_range = 5;
$qry_str = "";
$pagenum = paging_pagenum($current_page, $total_pages,
$page_range, $qry_str);
echo "หน้า: " . $pagenum;
echo "</td></tr>";
?>
</table>
</body>
</html>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2012-02-18 02:37:04 |
By :
Tongg |
View :
1038 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
//dbconn.inc.php
@mysql_connect("localhost", "root", "q1q2q3q4") or die(mysql_error());
@mysql_select_db("mkotu") or die(mysql_error());
?>
Code (PHP)
//paging.inc.php
<?php
function paging_start_row($current_page, $rows_per_page) {
return ($current_page - 1) * $rows_per_page;
}
function paging_stop_row($start_row, $rows_per_page, $total_rows) {
return (($start_row + $rows_per_page) < $total_rows) ? ($start_row + $rows_per_page) : $total_rows;
}
function paging_total_pages($total_rows, $rows_per_page) {
return ceil($total_rows / $rows_per_page);
}
function paging_pagenum($current_page, $total_pages, $page_range, $query_string) {
$page_start = $current_page - $page_range;
$page_end = $current_page + $page_range;
if($page_start < 1) {
$page_end += 1 - $page_start;
$page_start = 1;
}
if($page_end > $total_pages) {
$diff = $page_end - $total_pages;
$page_start -= $diff;
if($page_start < 1) {
$page_start = 1;
}
$page_end = $total_pages;
}
$url = $_SERVER['PHP_SELF'] . "?" . $query_string;
$result = "";
if($current_page > 1) {
$page = $current_page - 1;
$result .= " ";
$result .= "<a href=\"$url&page=$page\">Âé͹¡ÅѺ</a>";
}
if($page_start > 1) {
$page = $page_start - 1;
$result .= " ";
$result .= "<a href=\"$url&page=$page\">...</a>";
}
for($i = $page_start; $i <= $page_end; $i++) {
$result .= " ";
if($i == $current_page) {
$result .= $i;
}
else {
$result .= "<a href=\"$url&page=$i\">$i</a>";
}
$result .= " ";
}
if($page_end < $total_pages) {
$page = $page_end + 1;
$result .= " ";
$result .= "<a href=\"$url&page=$page\">...</a>";
}
if($current_page < $total_pages) {
$page = $current_page + 1;
$result .= " ";
$result .= "<a href=\"$url&page=$page\">¶Ñ´ä»</a>";
}
if($result == "") {
return "1";
}
else {
return $result;
}
}
?>
|
|
|
|
|
Date :
2012-02-18 02:40:15 |
By :
Tongg |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
@mysql_connect("localhost", "root", "q1q2q3q4") or die(mysql_error());
mysql_query("CREATE DATABASE mkotu;");
mysql_select_db("mkotu");
$sql = "CREATE TABLE university(
universityNo SMALLINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
nameUniversityTh VARCHAR(150),
nameUniversityEng VARCHAR(150),
facultyTh VARCHAR(150),
facultyEng VARCHAR(150),
branchTh VARCHAR(150),
branchEng VARCHAR(150),
couseNameTh VARCHAR(200),
couseNameEng VARCHAR(200),
courseInitialTh VARCHAR(200),
courseInitialEng VARCHAR(200),
creditAllCourse SMALLINT UNSIGNED);";
mysql_query($sql)or die(mysql_error());?>
ผมแก้มาสามวันแล้วช่วยผมหน่อบค้าบบบบ T-T
|
|
|
|
|
Date :
2012-02-18 02:41:27 |
By :
Tongg |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
บรรทัดที่ 37
Code (PHP)
$sql = " SELECT SQL_CALC_FOUND_ROWS *,
FROM university
ORDER BY universityNo DESC
LIMIT $start_row, $rows_per_page;";
เป็น
Code (PHP)
$sql = " SELECT *
FROM university
ORDER BY universityNo DESC
LIMIT $start_row, $rows_per_page;";
|
|
|
|
|
Date :
2012-02-18 08:28:18 |
By :
yogolas |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้ว ขอบคุณคร้าบบบ ^^
|
|
|
|
|
Date :
2012-02-18 17:58:18 |
By :
Tongg |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|