|
|
|
สร้างระบบค้นหาและแสดงข้อมูล.....ข้อมูลที่ค้นหาไม่แสดงผล |
|
|
|
|
|
|
|
การสร้างระบบค้นหาและแสดงข้อมูล
โค้ดรูปที่1
Code (PHP)
<body>
<form id="fmsearch" name="fmsearch" method="get" action="result.php">
<table width="279" border="1">
<tr>
<td width="158"><input type="text" name=" txtName " id=" txtName " /></td>
<td width="105"><input type="submit" name="Submit" id="Submit" value="ค้นหา" /></td>
</tr>
</table>
</form>
</body>
โค้ดรูปที่2
Code (PHP)
<?php require_once('Connections/dbcon.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}
$maxRows_rsResult = 5;
$pageNum_rsResult = 0;
if (isset($_GET['pageNum_rsResult'])) {
$pageNum_rsResult = $_GET['pageNum_rsResult'];
}
$startRow_rsResult = $pageNum_rsResult * $maxRows_rsResult;
$colname_rsResult = "-1";
if (isset($_GET[' txtName '])) {
$colname_rsResult = $_GET[' txtName '];
}
mysql_select_db($database_dbcon, $dbcon);
$query_rsResult = sprintf("SELECT * FROM rawmaterial WHERE name_m LIKE %s ORDER BY name_m ASC", GetSQLValueString("%" . $colname_rsResult . "%", "text"));
$query_limit_rsResult = sprintf("%s LIMIT %d, %d", $query_rsResult, $startRow_rsResult, $maxRows_rsResult);
$rsResult = mysql_query($query_limit_rsResult, $dbcon) or die(mysql_error());
$row_rsResult = mysql_fetch_assoc($rsResult);
if (isset($_GET['totalRows_rsResult'])) {
$totalRows_rsResult = $_GET['totalRows_rsResult'];
} else {
$all_rsResult = mysql_query($query_rsResult);
$totalRows_rsResult = mysql_num_rows($all_rsResult);
}
$totalPages_rsResult = ceil($totalRows_rsResult/$maxRows_rsResult)-1;
?><!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" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style4 { font-family: "TX Melittin";
font-size: 16px;
}
-->
</style>
</head>
<body>
<table width="464" border="1">
<tr>
<td width="72">เลข</td>
<td width="376">ชื่อ</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_rsResult['id']; ?></td>
<td><?php echo $row_rsResult['name_m']; ?></td>
</tr>
<?php } while ($row_rsResult = mysql_fetch_assoc($rsResult)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($rsResult);
?>
ข้อมูลไม่แสดงคับช่วยชี้แนะด้วย
Tag : PHP, JavaScript
|
|
|
|
|
|
Date :
2012-02-14 00:18:19 |
By :
หัดเล่น |
View :
1053 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|