ช่วยดูโค้ดให้หน่อยนะคะ จะดึงข้อมูลมาแสดงแต่ข้อมูลไม่ขึ้นค่ะ

ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา ช่วยดูโค้ดให้หน่อยนะคะ จะดึงข้อมูลมาแสดงแต่ข้อมูลไม่ขึ้นค่ะ

ช่วยดูโค้ดให้หน่อยนะคะ จะดึงข้อมูลมาแสดงแต่ข้อมูลไม่ขึ้นค่ะ
จะให้แสดงชื่อพนักงานว่าเข้ามาทำอะไรกับลูกค้าบ้าง ช่วยดูให้หน่อยนะคะ ขอบคุณมากๆค่ะ ไม่มี error ด้วยค่ะ 
<?php

/*if (!isset($_SESSION["user"])){
echo "<script language="javascript">";
						echo "alert('กรุณาเข้าสู่ระบบเพื่อใช้งานส่วนนี้!');";
						echo "window.location='login.php';";
						echo "</script>";
}*/
require_once('../Connections/Myconnect.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=utf-8" />
<title>history_customershow</title>
<style type="text/css">
body,td,th {
	font-size: 16px;
}
body {
	background-color: #C0D6D6;
}
</style>
</head>

<body background="bg.jpg" >
<?php require('topmenu.css');?>
<center>
<br />
  <table width="1229" height="152" border="0">
  <tr>
    <td width="1223" height="135"  border="0"><center>
      <img src="GSB_Logo.png" width="452" height="158" />
    </center></td>
  </tr>
  </table>
   
  <table width="1235" height="31" border="0">
    <tr>
      <td width="705" height="25" align="right" >
        <font color="#FFFFFF"> <form action=" " method="post"  autocomplete="on">
        <div id="headBottom">
         
<div id="topmenu">
  <ul>
    <li><a href="index_user.php"><span>หน้าแรก</span></a> 
        <a href="Account Summary.php"><span>เพิ่มบัญชีลูกค้า</span></a> 
        <a href="edit account.php"><span>แก้ไขบัญชีลูกค้า</span></a> 
        <a href="search_user.php"><span>ค้นหาแฟ้มงาน</span></a> 
        <a href="seeall_user.php"><span>ดูแฟ้มงานทั้งหมด</span></a> 
        <a href="contact.php"><span>แก้ไขข้อมูลส่วนตัว</span></a>
        <a href="history.php"><span>ประวัติการใช้งาน</span></a>  
        <a href="history_customer.php"><span>ประวัติการจัดการลูกค้า</span></a>
        </li>
  </ul>
</div>
<div class="bttnCheck"></div>
        </div>
      </form>
        </font>
        <div align="right" size="16">
    ยินดีต้อนรับ:<font color="#6633CC"><? echo $_SESSION["user"];?></font>&nbsp;<a href="login.php"<?php echo $logoutAction ?>"><font color="#000000">Logout</font></a></tr>
  </table>
  <table width="1233" border="0">
    <tr>
      <td width="1253" height="407" align="center" valign="top" bgcolor="#FFFFFF"><br /><table width="80%" border="0" align="center">
  <tr>
    <th scope="col"><fieldset><table width="100%" border="0" align="center">
      <tr>
        <th colspan="9" bgcolor="#FFFFFF" scope="col"><h3><span class="style3">&nbsp;ประวัติการจัดการลูกค้า</span></h3></th>
      </tr>
      <tr bgcolor="#C0D6D6">
        <th style="padding:1px 5px;" scope="col"><div align="center">ลำดับ</div></th>
        <th style="padding:1px 5px;" scope="col">ชื่อพนักงาน</th>
        <th style="padding:1px 5px;" scope="col"><div align="center">ประเภทสินเชื่อ</div></th>
        <th style="padding:1px 5px;" scope="col"><div align="center">เลขที่บัญชี</div></th>
      
        <th style="padding:1px 5px;" scope="col"><div align="center">สถานะแฟ้ม</div></th>
        <th style="padding:1px 5px;" scope="col"><div align="center">สถานะติดตามหนี่</div></th>
        <th style="padding:1px 5px;" scope="col"><div align="center">วันที่/เวลา</div></th>
        <th style="padding:1px 5px;" scope="col">สถานะระบบ</th>
      </tr>
      <? $sql = mysql_query ("select * from history h , customer c  where h.id_customer = c.id_customer  && h.id_customer = '$_REQUEST[id_customer]'") or die (mysql_error());
	  $i = 1;
	  while ($show = mysql_fetch_assoc ($sql)){
		  $sql2 = mysql_query ("select * from member where username = '$show[username]'");
		  $show2 = mysql_fetch_assoc ($sql2);
	  ?>
      <tr>
        <th style="padding:1px 5px;" scope="col"><div align="center"><? echo $i++;?></div></th>
        <th style="padding:1px 5px;" scope="col"><? echo $show2[name].'&nbsp;'.$show2[lastname];?></th>
        <th style="padding:1px 5px;" scope="col"><div align="center"><? echo $show[n_credit];?></div></th>
        <th style="padding:1px 5px;" scope="col"><div align="center"><? echo $show[id_credit];?></div></th>
        
        <th style="padding:1px 5px;" scope="col"><div align="center"><? echo $show[status_doc];?></div></th>
        <th style="padding:1px 5px;" scope="col"><div align="center"><? echo $show[follow_doc1];?></div></th>
        <th style="padding:1px 5px;" scope="col"><div align="center"><? echo $show[date_time];?></div></th>
        <th style="padding:1px 5px;" scope="col"><? if($show[status]==1){echo 'เพิ่มเอกสาร';} else {echo 'แก้ไขเอกสาร';}?></th>
      </tr>
      <? }?>
      <tr>
        <th colspan="9" style="padding:1px 5px;" scope="col"><? if(mysql_num_rows($sql)==0){?> <font size="5" color="#FF0000">ไม่พบข้อมูล!</font><? } ?></th>
        </tr>
      
      </table>
    </fieldset></th>
  </tr>
</table></td>
    </tr>
  </table>
  

</center>
</body>
</html>

Databases


Jiijibe 101.109.64.xxx 22-01-2015 19:30:04

คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
  • เปลี่ยน


    ( หรือ เข้าใช้งานผ่าน Social Login )

 ความคิดเห็นที่ 1
จุดสังเกต คือ บรรทัด 83 นะครับ

ลองเปลี่ยน &&   เป็น AND  ดู

และลอง ดูว่า $_REQUEST[id_customer] มีค่ามาหรือ ยัง  ตอนรัน อาจ แทน ค่า ตรงๆ ไปเลยก็ได้  

$sql = mysql_query ("select * from history h , customer c  where h.id_customer = c.id_customer  and h.id_customer = 3") or die (mysql_error());  


wowowow 61.90.56.xxx 23-01-2015 09:17
 ความคิดเห็นที่ 2
บรรทัด 87

  while($show2 = mysql_fetch_assoc ($sql2)){
    $show2[name];

}  
อันนี้ไม่แน่ใจจะมีผลไรไหมนะครับ   จากโค้ดเดิม ถ้า มีแค่ เรคคอดเดียว คงทำงานได้ปกติ แต่ถ้ามีหลายเรคคอด จะทำงานผิดก็ได้ ลองเช็คดูครับ

หวังว่าคงจะพอช่วยได้บ้างนะครับ


wowowow 61.90.56.xxx 23-01-2015 09:28
 ความคิดเห็นที่ 3
ขอบคุณมากค่ะตอนนี้ข้อมูลขึ้นแล้ว
แต่อยากให้มันแยกเป็นชื่อของพนักงานที่ทำการแก้ไขหรือเพิ่มลูกค้าคนนั้นอ่ะค่ะ
ตอนนี้มันไม่แยกแต่ขึ้นทั้งหมดเลยค่ะ 

หน้านี้จะแสดงลูกค้าทั้งหมดแล้วพอกดคลิก แสดง


jiijibe 118.173.95.xxx 25-01-2015 12:33
 ความคิดเห็นที่ 4
จะขึ้นหน้า 


jiijibe 118.173.95.xxx 25-01-2015 12:34
 ความคิดเห็นที่ 5
ส่งค่า id  ไปกับลิงค์ครับ


ตัวอย่างนะครับ

หน้าลูกค้าทั้งหมด
<table style="width:100%">
  <tr>
    <td>ประเภทสินเชื่อ</td>
    <td>เลขที่บัญชี</td>
    <td>ชื่อ</td>
    <td>นามสกุล</td>
    <td>รายงาน</td>
  </tr>
  <?php
    $sql = mysql_query ("select * from customer ") or die (mysql_error());  
    while ($show = mysql_fetch_assoc ($sql)){ 
  ?> 
  <tr>
    <td><?php echo $show['ประเภทสินเชื่อ']?></td>
    <td><?php echo $show['เลขที่บัญชี']?></td>
    <td><?php echo $show['ชื่อ']?></td>
    <td><?php echo $show['นามสกุล']?></td>
    <td><a href="Page2.php?customerID=<?php echo $show['id_customer'] ?>">แสดง</a></td>
  </tr>
  <?php
  }
  ?>

</table> 


หน้าลูกค้าคนที่เลือก

 <table style="width:100%">
  <tr>
    <td>ประเภทสินเชื่อ</td>
    <td>เลขที่บัญชี</td>
    <td>ชื่อ</td>
    <td>นามสกุล</td>
    
  </tr>
  <?php
    $id = $_GET['customerID'];
    $sql = mysql_query ("select * from customer where id_customer = $id") or die (mysql_error());  
    while ($show = mysql_fetch_assoc ($sql)){ 
  ?> 
  <tr>
    <td><?php echo $show['ประเภทสินเชื่อ']?></td>
    <td><?php echo $show['เลขที่บัญชี']?></td>
    <td><?php echo $show['ชื่อ']?></td>
    <td><?php echo $show['นามสกุล']?></td>   
  </tr>
  <?php
  }
  ?>

</table> 


ดูแป็นแนวทางครับ sql ผมสมมุติขึ้นมา หลักการ แค่ ส่งไอดี มาแบบ GET จากลิงค์ที่กด แล้วอีกหน้า ก็เขียนเงื่อนไข โดยไอดีที่ได้มา นะครับ
หวังว่าจะเข้าใจนะ ผมก็อธิบายไม่ค่อยเป็น


wowowow 171.96.244.xxx 25-01-2015 18:55
 ความคิดเห็นที่ 6
ขอบคุณมากๆค่ะ


jiijibe 101.109.65.xxx 26-01-2015 10:14
1






เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ