ช่วยดูโค้ดให้หน่อยครับ ว่าผิดพลาดตรงไหน ผมจะทำค้นหาข้อมูลอ่ะครับ ขอบคุณล่วงหน้านะครับ
ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา ช่วยดูโค้ดให้หน่อยครับ ว่าผิดพลาดตรงไหน ผมจะทำค้นหาข้อมูลอ่ะครับ ขอบคุณล่วงหน้านะครับ
ช่วยดูโค้ดให้หน่อยครับ ว่าผิดพลาดตรงไหน ผมจะทำค้นหาข้อมูลอ่ะครับ ขอบคุณล่วงหน้านะครับ
Copy
นี่โค้ดทั้งหมดครับ ละมันขึ้น Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:xampphtdocspmjprojectAPT_Projectmain.php on line 279 ผมก็ไม่รู้เป็นที่อะไร พยายามทำในส่วนของค้นหาอ่ะครับ รบกวนผู้รู้ช่วยผมที ผมมือใหม่หัดเขียน php
<?php
session_start();
if($_SESSION['UserID'] == "")
{
echo "Please Login!";
exit();
}
if($_SESSION['Status'] != "ADMIN")
{
echo "This page for Admin only!";
exit();
}
mysql_connect("localhost","root","abc456");
mysql_select_db("main");
$strSQL = "SELECT * FROM member WHERE UserID = '".$_SESSION['UserID']."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
?>
<html>
<head>
<meta charset="utf-8">
<title>APT_Project</title>
<style>
@import "global.css";
caption {
text-align: left;
padding-bottom: 3px;
}
#c1 {
width: 50px;
}
#c2 {
width: 100px;
}
#c3 {
width: 100px;
}
#c4 {
width: 60px;
}
#c5 {
width: 100px;
}
#c6 {
width: 100px;
}
#c7 {
width: 100px;
}
#c8 {
width: 100px;
}
#c9 {
width: 100px;
}
#c10 {
width: 100px;
}
#c11 {
width: 100px;
}
#c12 {
width: 100px;
}
#c13 {
width: 300px;
}
#c14 {
width: 100px;
}
#c15 {
width: 150px;
}
#c16 {
width: 150px;
}
#c17 {
width: 100px;
}
#c18 {
width: 100px;
}
#c19 {
width: 100px;
}
#c20 {
width: 100px;
}
#c21 {
width: 100px;
}
#c22 {
width: 100px;
}
#c23 {
width: 110px;
}
table th {
background: green;
color: yellow;
padding: 5px;
border-right: solid 1px white;
font-size:12px;
}
tr:nth-of-type(odd) {
background: lavender;
}
tr:nth-of-type(even) {
background: whitesmoke;
}
td {
vertical-align: top;
padding: 3px 0px 3px 5px;
border-right: solid 1px white;
}
td:first-child, td:last-child {
text-align: center;
}
td a:hover {
color: red;
}
p#pagenum {
width: 90%;
text-align: center;
margin: 5px;
}
#dialog {
display: none;
font-size: 14px !important;
}
#form-main [type=text], #form-main textarea{
width: 370px;
background: lavender;
border: solid 1px gray;
padding: 3px;
margin-bottom: 3px;
font-size: 14px;
}
#form-main textarea {
resize: none;
overflow: auto;
}
#form-search {
width: 750px;
margin: auto;
}
</style>
<link href="js/jquery-ui.min.css" rel="stylesheet">
<script src="js/jquery-2.1.1.min.js"> </script>
<script src="js/jquery-ui.min.js"> </script>
<script src="js/jquery.blockUI.js"> </script>
<script>
$(function() {
$('#bt-search').click(function() {
$('#form-search').submit();
});
$('#add-main').click(function() { //คลิกปุ่ม "เพิ่มรายการข้อมูล"
$('#form-main')[0].reset();
$('#action').val('add');
showDialog();
});
$('#send').click(function() { //คลิกปุ่ม "ส่งข้อมูล" ที่อยู่ในไดอะล็อก
var data = $('#form-main').serializeArray();
ajaxSend(data);
});
$('button.edit').click(function() {
var tr = $(this).parent().parent(); //parent() ครั้งแรกจะได้ <td> ที่บรจจุปุ่มที่ถูกคลิก parent() ครั้งที่สอง จะได้ <tr> ที่เกิดอีเวนต์
$('#A2_date').val(tr.children(':eq(1)').text());
$('#A3').val(tr.children(':eq(2)').text());
$('#A4').val(tr.children(':eq(3)').text());
$('#A5').val(tr.children(':eq(4)').text());
$('#A6').val(tr.children(':eq(5)').text());
$('#A7').val(tr.children(':eq(6)').text());
$('#A8').val(tr.children(':eq(7)').text());
$('#A9').val(tr.children(':eq(8)').text());
$('#A10').val(tr.children(':eq(9)').text());
$('#A11').val(tr.children(':eq(10)').text());
$('#A12').val(tr.children(':eq(11)').text());
$('#A13').val(tr.children(':eq(12)').text());
$('#A14').val(tr.children(':eq(13)').text());
$('#A15').val(tr.children(':eq(14)').text());
$('#A16').val(tr.children(':eq(15)').text());
$('#A17').val(tr.children(':eq(16)').text());
$('#A18').val(tr.children(':eq(17)').text());
$('#A19').val(tr.children(':eq(18)').text());
$('#A20').val(tr.children(':eq(19)').text());
$('#A21').val(tr.children(':eq(20)').text());
$('#A22').val(tr.children(':eq(21)').text());
$('#A1_id').val($(this).attr('data-id'));
$('#action').val('edit');
showDialog();
});
$('button.del').click(function() {
if(!(confirm("ยืนยันการลบรายการข้อมูลนี้"))) {
return;
}
var id = $(this).attr('data-id');
ajaxSend({'action': 'del', 'A1_id': id});
});
});
function resetForm() {
$('#form-pro')[0].reset();
$('input:file').clearInputs(); //อยู่ในไลบรารี form.js
}
function showDialog() {
$('#dialog').dialog({
title: 'รายการข้อมูล',
width: 'auto',
modal: true,
position: { my: "center top", at: "center top", of: $('nav')}
});
}
function ajaxSend(dataJSON) {
$.ajax({
url: 'main-action.php',
data: dataJSON,
type: 'post',
dataType:"html",
beforeSend: function() {
$.blockUI({message:'<h3>กำลังส่งข้อมูล...</h3>'});
},
complete: function() {
$.unblockUI();
location.reload();
}
});
}
</script>
</head>
<body><?php include "top_main.php"; ?>
<article>
<?php
include "dblink.php";
include "lib/pagination.php";
$sql = "SELECT * FROM mains";
$result = page_query($link, $sql, 20);
$first = page_start_row();
$last = page_stop_row();
$total = page_total_rows();
if($total == 0) {
$first = 0;
}
?>
<form id="form_search" name="form_search" method="get" action="">
<dd><input type="radio" name="field" value="1">ค้นหาข้อมูลทั้งหมด<br><br>
<input type="radio" name="field" value="A13_name">ค้นหาข้อมูลจากคำหรือประโยคในรายการ ( ตย.ค่าใช้จ่าย..... ) ||
<input type="text" name="A13_key"><br><br>
<input type="radio" name="field" value="A2_name">ค้นหาข้อมูลจากวันที่ ( ตย.01/01/2558 ) ||
<input type="text" name="A2_key"><br><br>
<input type="submit" name="button" id="button" value="ค้นหา" />
<input type="button" name="btn_reset" value="Reset" onclick="window.location='main.php'">
</form>
<?php
$field = "ทั้งหมด";
$sql = "SELECT * FROM mains ;
if(($_GET['field'] == "A13_name") && !empty($_GET['A13_key'])) {
$sql .= " WHERE A13 LIKE '%" . $_GET['A13_key'] . "%'";
$field = "ค้นหาข้อมูลจากคำหรือประโยคในรายการ : '" . $_GET['A13_key'] . "'";
}
else if(($_GET['field'] == "A2_name") && !empty($_GET['A2_key'])) {
$sql .= " WHERE A2_date '%" . $_GET['A2_key'] . "%'";
$field = "ค้นหาข้อมูลจากวันที่ : '" . $_GET['A2_key'] . "'";
}
$sql .= " ORDER BY A1_id DESC";
$result = page_query($link, $sql, 10);
$first = page_start_row();
$last = page_stop_row();
$total = page_total_rows();
if($total == 0) {
$first = 0;
}
?>
//<table>
<caption>
<?php echo "ข้อมูลลำดับที่ $first - $last จากทั้งหมด $total"; ?>
<button id="add-main">เพิ่มรายการข้อมูล</button>
</caption>
<colgroup><col id="c1"><col id="c2"><col id="c3"><col id="c4"><col id="c5"><col
id="c6"><col id="c7"><col id="c8"><col id="c9"><col id="c10"><col
id="c11"><col id="c12"><col id="c13"><col id="c14"><col id="c15"><col
id="c16"><col id="c17"><col id="c18"><col id="c19"><col id="c20"><col id="c21"><col id="c22"><col id="c23"></colgroup>
<?php
include "lib/IMGallery/imgallery-no-jquery.php";
$row = $first;
while($pro = mysqli_fetch_array($result)) {
?>
<tr><th>ลำดับ</th><th>ว/ด/ป</th><th>เลขที่ บย</th><th>รหัสลูกหนี้รายตัว</th><th>เลขที่ บคส</th><th>เลขที่ บร</th>
<th>เลขที่ บส</th><th>เลขที่ ฎีกา</th><th>เลขที่ บฝ</th><th>เลขที่ บค</th><th>เลขที่ บถ</th><th>เลขที่เช็ค</th>
<th>รายการ</th><th>ว/ด/ป ครบกำหนด</th><th>ชื่อผู้ยืม</th><th>ชื่อผู้รับเงิน</th><th>เงินยืม (บาท)</th><th>เงินฝากธนาคาร (บาท)</th>
<th>ใบสำคัญ (บาท)</th><th>หน่วยงานย่อย (บาท)</th><th>เงินสดคงเหลือ (บาท)</th><th>เงินรับ (บาท)</th><th>คำสั่ง</th></tr>
<?php
$field = "ทั้งหมด";
$row = $first;
while($main = mysqli_fetch_array($result)) {
if(!empty($main['website'])) {
$main['A13'] = "<a href="{$main['website']}" target="_blank">{$main['A13']}</a>";
}
?>
<tr>
<td><?php echo $row; ?></td>
<td><?php echo $main['A2_date']; ?></td>
<td><?php echo $main['A3']; ?></td>
<td><?php echo $main['A4']; ?></td>
<td><?php echo $main['A5']; ?></td>
<td><?php echo $main['A6']; ?></td>
<td><?php echo $main['A7']; ?></td>
<td><?php echo $main['A8']; ?></td>
<td><?php echo $main['A9']; ?></td>
<td><?php echo $main['A10']; ?></td>
<td><?php echo $main['A11']; ?></td>
<td><?php echo $main['A12']; ?></td>
<td><?php echo $main['A13']; ?></td>
<td><?php echo $main['A14']; ?></td>
<td><?php echo $main['A15']; ?></td>
<td><?php echo $main['A16']; ?></td>
<td><?php echo $main['A17']; ?></td>
<td><?php echo $main['A18']; ?></td>
<td><?php echo $main['A19']; ?></td>
<td><?php echo $main['A20']; ?></td>
<td><?php echo $main['A21']; ?></td>
<td><?php echo $main['A22']; ?></td>
<td>
<button class="edit" data-id="<?php echo $main['A1_id']; ?>">แก้ไข</button>
<button class="del" data-id="<?php echo $main['A1_id']; ?>">ลบ</button>
</td>
</tr>
<?php
$row++;
}
?>
</table>
<?php
if(page_total() > 1) { //ให้แสดงหมายเลขเพจเฉพาะเมื่อมีมากกว่า 1 เพจ
echo '<p id="pagenum">';
page_echo_pagenums();
echo '</p>';
}
?>
<div id="dialog">
<form id="form-main">
<input type="hidden" name="action" id="action" value="">
<input type="hidden" name="A1_id" id="A1_id" value="">
<input type="text" name="A2_date" id="A2_date" placeholder="ว/ด/ป (ตัวอย่าง 01/01/2558)"><br>
<input type="text" name="A3" id="A3" placeholder="เลขที่ บย (ตัวอย่าง บย.001/58)"><br>
<input type="text" name="A4" id="A4" placeholder="รหัสลูกหนี้รายตัว (ตัวอย่าง a1)"><br>
<input type="text" name="A5" id="A5" placeholder="เลขที่ บคส (ตัวอย่าง บคส.001/58)"><br>
<input type="text" name="A6" id="A6" placeholder="เลขที่ บร (ตัวอย่าง บร.001/58)"><br>
<input type="text" name="A7" id="A7" placeholder="เลขที่ บส (ตัวอย่าง บส.1/58)"><br>
<input type="text" name="A8" id="A8" placeholder="เลขที่ ฎีกา (ตัวอย่าง ฎ.1/58)"><br>
<input type="text" name="A9" id="A9" placeholder="เลขที่ บฝ (ตัวอย่าง บฝ.1/58)"><br>
<input type="text" name="A10" id="A10" placeholder="เลขที่ บค (ตัวอย่าง บค.001/58)"><br>
<input type="text" name="A11" id="A11" placeholder="เลขที่ บถ (ตัวอย่าง บถ.1/58)"><br>
<input type="text" name="A12" id="A12" placeholder="เลขที่เช็ค (ตัวอย่าง 123456)"><br>
<textarea name="A13" id="A13" placeholder="รายการ (ตัวอย่าง ค่าใช้จ่าย.............)"></textarea><br>
<input type="text" name="A14" id="A14" placeholder="ว/ด/ป ครบกำหนด (ตัวอย่าง 01/01/2558)"><br>
<input type="text" name="A15" id="A15" placeholder="ชื่อผู้ยืม (ตัวอย่าง พท.รักชาติ สุดใจ)"><br>
<input type="text" name="A16" id="A16" placeholder="ชื่อผู้รับเงิน (ตัวอย่าง รอญ.พลอยใส สุดใจ)"><br>
<input type="text" name="A17" id="A17" placeholder="เงินยืม (บาท) (ตัวอย่าง 9,999,999)"><br>
<input type="text" name="A18" id="A18" placeholder="เงินฝากธนาคาร (บาท) (ตัวอย่าง 9,999,999)"><br>
<input type="text" name="A19" id="A19" placeholder="ใบสำคัญ (บาท) (ตัวอย่าง 9,999,999)"><br>
<input type="text" name="A20" id="A20" placeholder="หน่วยงานย่อย (บาท) (ตัวอย่าง 9,999,999)"><br>
<input type="text" name="A21" id="A21" placeholder="เงินสดคงเหลือ (บาท) (ตัวอย่าง 9,999,999)"><br>
<input type="text" name="A22" id="A22" placeholder="เงินรับ (บาท) (ตัวอย่าง 9,999,999)"><br><br>
<button type="button" id="send">ส่งข้อมูล</button>
</form>
</div>
</article>
</body>
</html>
คำแนะนำ และการใช้งาน
สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก
- ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา
โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ