|
|
|
พอทำการ add ข้อมูล ข้อมูลไม่โชว์ในหน้าเว็บ ขึ้นแต่ในฐานข้อมูลค่ะ |
|
|
|
|
|
|
|
พอเพิ่มข้อมูลแล้วมันไม่โชว์ในหน้าโชว์ข้อมูลอ่าค่ะ แต่ในฐานข้อมูลแอดเข้า
ช่วยดูให้หน่อยค่ะ ว่าผิดตรงไหน
หน้า add ข้อมูล
<?php
require_once('Connections/AddDataCustomers.php');
echo "<br>";
include("session_admin.php");
include("header_admin.php");
?>
<?php
$sess_username=$_SESSION['UserID'];
?>
<?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;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO data_customers (ctm_name, ctm_surname, ctm_product, ctm_model, no_imei, ctm_tel, ctm_date, ctm_fix, User_add, pp_add ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['ctm_name'], "text"),
GetSQLValueString($_POST['ctm_surname'], "text"),
GetSQLValueString($_POST['ctm_product'], "text"),
GetSQLValueString($_POST['ctm_model'], "text"),
GetSQLValueString($_POST['no_imei'], "text"),
GetSQLValueString($_POST['ctm_tel'], "int"),
GetSQLValueString($_POST['ctm_date'], "date"),
GetSQLValueString($_POST['ctm_fix'], "text"),
GetSQLValueString($_POST['pp_add'], "text"),
GetSQLValueString($_POST['UserID'], "text"));
mysql_select_db($database_AddDataCustomers, $AddDataCustomers);
$Result1 = mysql_query($insertSQL, $AddDataCustomers) or die(mysql_error());
$insertGoTo = "data_customer.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
//header(sprintf("Location: %s", $insertGoTo));
?>
<script> window.location="data_customer.php"; </script>
<?
}
?>
<!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" />
<title>After Sale Service</title>
</head>
<?php
mysql_connect("localhost","aor","aor1234") or die(mysql_error());
mysql_select_db("after_sale");
?>
<body>
<p> </p>
<p> </p>
<p> </p>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table border="0" align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td align="center"><p>เพิ่มข้อมูลใหม่</p></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"></td>
<td>
<input type="text" class="form-control" placeholder="ชื่อ" name="ctm_name" id="ctm_name" value="" size="32">
</td>
</tr>
<td><br/></td>
<tr valign="baseline">
<td nowrap="nowrap" align="right"></td>
<td> <input type="text" class="form-control" placeholder="นามสกุล" name="ctm_surname" value="" size="32" /></td>
</tr>
<td><br/></td>
<tr valign="baseline">
<td nowrap="nowrap" align="right"></td>
<td>
<input type="text" class="form-control" placeholder="เบอร์ติดต่อ" name="ctm_tel" value="" size="32" />
<input type="hidden" name="UserID" value="<?=$sess_username?>" />
</td>
</tr>
<td><br/></td>
<tr valign="baseline">
<td nowrap="nowrap" align="right"></td>
<td> <input type="text" class="form-control" placeholder="IMEI" name="no_imei" value="" size="32" /></td>
</tr>
<td><br/></td>
<tr valign="baseline">
<td nowrap="nowrap" align="right">วันที่มาซ่อม(ป-ด-ว):</td>
<td>
<input type="text" class="form-control" name="ctm_date" value="<?php echo date('Y-m-d'); ?>" size="32" />
</td>
</tr>
<td><br/></td>
<tr valign="baseline">
<td nowrap="nowrap" align="right">ยี่ห้อมือถือ:</td>
<td>
<select name="ctm_product" id="ctm_product">
<?php
$strSQL = "SELECT * FROM add_product";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["brand"];?>"><?=$objResuut["brand"];?></option>
<?php
}
?>
</select>
<?php echo " ";?> รุ่น:
<select name="ctm_model" id="ctm_model">
<?php
$strSQL = "SELECT * FROM add_product";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["model"];?>">
<?=$objResuut["model"];?>
</option>
<?php
}
?>
</select></td>
</tr>
<td><br/></td>
<tr valign="baseline">
<td nowrap="nowrap" align="right">บริการที่เข้ารับ:</td>
<td>
<select name="ctm_fix" id="ctm_fix">
<?php
$strSQL = "SELECT * FROM service";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["service_id"];?>"><?=$objResuut["service_fix"];?></option>
<?php
}
?>
</select>
<?php echo " ";?> ผู้ให้บริการ:
<select name="pp_add" id="pp_add">
<?php
$strSQL = "SELECT * FROM member";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["UserID"];?>"><?=$objResuut["Username"];?></option>
<?php
}
?>
</select>
</td>
</tr>
<td><br/></td>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><center>
<button type="submit" class="btn btn-success">บันทึก</button>
<button type="reset" name="resend" id="resend" class="btn btn-danger">ล้างข้อมูลทั้งหมด</button>
</center></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</body>
</html>
หน้าโชว์ข้อมูล
<?php require_once('Connections/AddDataCustomers.php');
echo "<br>";
include("session_admin.php");
include("header_admin.php");
?>
<?php
$sess_username=$_SESSION['UserID'];
?>
<?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_AddDataCustomers, $AddDataCustomers);
$query_ShowData = "SELECT * FROM data_customers inner join service on ctm_fix = service_id WHERE User_add ='$sess_username' ";
$ShowData = mysql_query($query_ShowData, $AddDataCustomers) or die(mysql_error());
$row_ShowData = mysql_fetch_assoc($ShowData);
$i=1;
$Num_Rows = mysql_num_rows($ShowData);
$Per_Page = 20; // ปรับตรงนี้ถ้าอยากให้แต่ละหน้าแสดงกี่แถว
$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;
}
elseif(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$query_ShowData .=" LIMIT $Page_Start , $Per_Page";
$ShowData = mysql_query($query_ShowData);
?>
<!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" />
<title>After Sale Service</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/bootstrap-theme.min.css" />
</head>
<body>
<p> </p>
<p> </p>
<p> </p>
<center><p><h3>ข้อมูลลูกค้าที่นำเครื่องมาซ่อม</h3></p></center>
<p> </p>
<center><form id="form1" name="form1" method="post" action="search.php">
<p>
<label for="Month"> ค้นหาจาก เดือน : </label>
<select name="Month" id="Month">
<option value="" <? if($Month=='') echo " selected='selected'" ?> > ทั้งหมด</option>
<option value="01" <? if($Month=='01') echo " selected='selected'" ?> > มกราคม</option>
<option value="02" <? if($Month=='02') echo " selected='selected'" ?> > กุมภาพันธ์</option>
<option value="03" <? if($Month=='03') echo " selected='selected'" ?> > มีนาคม</option>
<option value="04" <? if($Month=='04') echo " selected='selected'" ?> > เมษายน</option>
<option value="05" <? if($Month=='05') echo " selected='selected'" ?> > พฤษภาคม</option>
<option value="06" <? if($Month=='06') echo " selected='selected'" ?> > มิถุนายน</option>
<option value="07" <? if($Month=='07') echo " selected='selected'" ?> > กรกฎาคม</option>
<option value="08" <? if($Month=='08') echo " selected='selected'" ?> > สิงหาคม</option>
<option value="09" <? if($Month=='09') echo " selected='selected'" ?> > กันยายน</option>
<option value="10" <? if($Month=='10') echo " selected='selected'" ?> > ตุลาคม</option>
<option value="11" <? if($Month=='11') echo " selected='selected'" ?> > พฤศจิกายน</option>
<option value="12" <? if($Month=='12') echo " selected='selected'" ?> > ธันวาคม</option>
</select>
<label for="Year"> ปี : </label>
<select name="Year" id="Year">
<option value="" > ทั้งหมด</option>
<?php for($int_year = 0;$int_year < 10;$int_year++) { ?>
<option value="<?php echo date("Y") - $int_year ?>"><?php echo date("Y") - $int_year ?></option>
<?php } ?>
</select>
<label for="ctm_fix">บริการที่เข้ารับ:</label>
<select name="ctm_fix" id="ctm_fix">
<option value="">--ทั้งหมด--</option>
<?php
$strSQL = "SELECT * FROM service";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["service_id"];?>">
<?=$objResuut["service_fix"];?>
</option>
<?php
}
?>
</select>
<label for="word">ชื่อ:</label>
<input type="text" name="word" id="word" />
<input type="submit" name="btnsearch" id="btnsearch" value="Submit" />
</p>
<p> </p>
</form></center>
<a class="btn btn-primary" href="data-table-excel.php" target="_blank" role="button">ดาวน์โหลดไฟล์ Excel</a>
<table class="table table-hover" align="center">
<tr>
<td width="42" align="center" bgcolor="#999999"><strong>ลำดับ</strong></td>
<td width="151" align="center" bgcolor="#999999"><strong>ชื่อ</strong></td>
<td width="170" align="center" bgcolor="#999999"><strong>นามสกุล</strong></td>
<td width="172" align="center" bgcolor="#999999"><strong>ยี่ห้อมือถือ</strong></td>
<td width="127" align="center" bgcolor="#999999"><strong>รุ่น</strong></td>
<td width="127" align="center" bgcolor="#999999"><strong>IMEI</strong></td>
<td width="127" align="center" bgcolor="#999999"><strong>เบอร์ติดต่อ</strong></td>
<td width="145" align="center" bgcolor="#999999"><strong>วันที่มาซ่อม</strong></td>
<td width="132" align="center" bgcolor="#999999"><strong>บริการที่เข้ารับ</strong></td>
<td width="132" align="center" bgcolor="#999999"><strong>ผู้ให้บริการ</strong></td>
<td width="127" align="center" bgcolor="#999999"><strong>ผู้กรอกข้อมูล</strong></td>
<td colspan="2" align="center" bgcolor="#999999"><strong>ตัวเลือก</strong></td>
</tr>
<?php while ($row_ShowData = mysql_fetch_assoc($ShowData)) { ?>
<tr>
<td align="center"><?php echo (($Page - 1) * ($Per_Page)) + $i; ?></td>
<td align="center"><?php echo $row_ShowData['ctm_name']; ?></td>
<td align="center"><?php echo $row_ShowData['ctm_surname']; ?></td>
<td align="center"><?php echo $row_ShowData['ctm_product']; ?></td>
<td align="center"><?php echo $row_ShowData['ctm_model']; ?></td>
<td align="center"><?php echo $row_ShowData['no_imei']; ?></td>
<td align="center"><?php echo $row_ShowData['ctm_tel']; ?></td>
<td align="center"><?php echo $row_ShowData['ctm_date']; ?></td>
<td align="center"><?php echo $row_ShowData['service_fix']; ?></td>
<td align="center"><?php echo $row_ShowData['User_add']; ?></td>
<td align="center"><?php echo $row_ShowData['pp_add']; ?></td>
<td width="20" align="center"><a href="delete.php?ctm_id=<?php echo $row_ShowData['ctm_id']; ?>" onclick="return confirm('คุณแน่ใจที่จะลบ <?php echo $row_ShowData['ctm_name']; ?>');"><button type="button" class="btn btn-danger">ลบ</button></a></td>
<td width="42" align="center"><a href="update.php?no=<?=$i;?>&ctm_id=<?php echo $row_ShowData['ctm_id']; ?>"><button type="button" class="btn btn-warning">แก้ไข</button></a></td>
</tr>
<?php ++$i; } ?>
</table>
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
<?php
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();
?>
<p> </p>
<script src="js/bootstrap.min.js"> </script>
<script src="https://code.jquery.com/jquery.js"></script>
</body>
</html>
<?php
mysql_free_result($ShowData);
?>
Tag : PHP
|
|
|
|
|
|
Date :
2014-01-09 12:54:07 |
By :
aorplus |
View :
802 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PHP MySQL List Record
เขียนง่ายกว่าครับ
|
|
|
|
|
Date :
2014-01-09 20:44:55 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|