คือเราrecordsetข้อมูลทั้งหมดออกมาจาก db แล้วเราต้องการใส่คำสั่งให้ พิมพ์ ออกมา แค่อันที่เราต้องการไม่ใช่ทั้งหมด

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

คือเราrecordsetข้อมูลทั้งหมดออกมาจาก db แล้วเราต้องการใส่คำสั่งให้ พิมพ์ ออกมา แค่อันที่เราต้องการไม่ใช่ทั้งหมด
<?php require_once('Connections/ldo.php'); ?>
<?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_ldo, $ldo);
$query_All = "SELECT * FROM ldo_detail";
$All = mysql_query($query_All, $ldo) or die(mysql_error());
$row_All = mysql_fetch_assoc($All);
$totalRows_All = mysql_num_rows($All);
?>
<!doctype html>
<html>
<head>
<meta charset="windows-874">
<title>Untitled Document</title>
<style type="text/css">
body,td,th {
	font-family: "Angsana New";
	font-size: 24px;
}
</style>
</head>

<body>
<table width="1024" border="1" align="center">
  <tr>
    <td align="center"><table width="1024" border="1">
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
      <p>&nbsp;</p>
      <?php do { ?>
        <table width="1000" border="0" align="center">
          <tr>
            <td width="80" align="right"><strong>เรียน :</strong></td>
            <td width="337"><?php echo $row_All['divistions']; ?></td>
            <td width="38">&nbsp;</td>
            <td width="325">&nbsp;</td>
            <td width="101" align="center"><strong>สถานะ</strong></td>
            <td width="79">&nbsp;</td>
          </tr>
          <tr>
            <td align="right"><strong>เรื่อง :</strong></td>
            <td><?php echo $row_All['story']; ?></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td align="center"><?php echo $row_All['status']; ?></td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td align="right">&nbsp;</td>
            <td>รายละเอียดการขอใช้บริการ</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td align="right"><strong>วันที่</strong> :</td>
            <td><?php echo $row_All['day']; ?> <?php echo $row_All['month']; ?> <?php echo $row_All['year']; ?></td>
            <td align="center">เวลา</td>
            <td><?php echo $row_All['str_time']; ?>ถึง <?php echo $row_All['end_time']; ?></td>
            <td align="center">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td colspan="2"><table width="353" border="0">
              <tr>
                <td align="left"><strong>ห้องประชุม</strong></td>
                </tr>
            </table>  </td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td colspan="3"><table width="450" border="0">
              <tr>
                <td width="101"><?php echo $row_All['meeting room']; ?></td>
                <td width="333"><?php echo $row_All['detail_room_meeting']; ?></td>
                </tr>
            </table></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><strong>อุปกรณ์</strong></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td colspan="5"><?php echo $row_All['Tools']; ?></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><strong>การจัดโต๊ะ</strong></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><?php echo $row_All['manage_table']; ?></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><table width="324" height="40" border="0">
              <tr>
                <td width="97" align="right"><strong>ผู้ขอใช้บริการ :</strong></td>
                <td width="211"><?php echo $row_All['applicant']; ?></td>
                </tr>
              </table>
              <table width="325" height="37" border="0">
                <tr>
                  <td width="97" align="right"><strong>ตำแหน่ง :</strong></td>
                  <td width="212"><?php echo $row_All['job1']; ?></td>
                </tr>
              </table></td>
            <td>&nbsp;</td>
            <td><table width="324" height="40" border="0">
              <tr>
                <td width="97" align="right"><strong>ผู้ให้บริการ :</strong></td>
                <td width="211"><?php echo $row_All['Facilitator']; ?></td>
                </tr>
              </table>
              <table width="325" height="37" border="0">
                <tr>
                  <td width="97" align="right"><strong>ตำแหน่ง :</strong></td>
                  <td width="212"><?php echo $row_All['job2']; ?></td>
                </tr>
            </table></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
        <blockquote>
          <p>-------------------------------------------------------------------------------------------------------------------------------------------------------</p>
        </blockquote>
        <?php } while ($row_All = mysql_fetch_assoc($All)); ?>
    <p>&nbsp;</p></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($All);
?>


Mos Kritsada 101.51.127.xxx 16-04-2015 16:03:36

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

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


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


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

 ความคิดเห็นที่ 1
กำหนดเงื่อนไขที่เราต้องการ แล้วทำเป้นคำสั่ง sql แล้วนำไปใส่ในเงื่อนไขการแสดง 


ninenik 171.96.12.xxx 16-04-2015
 ความคิดเห็นที่ 2
ขอถามอีกคำถามนะครับ ผม Insert record แล้วมัน error โดยที่ผมทำ ในฟิวด์นึงเป็น auto_increment ต้องทำอย่างไร
<?php 
ob_start();
require_once('Connections/ldo.php'); ?>
<?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 `55555` (No., rrrr, h) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['No'], "int"),
                       GetSQLValueString($_POST['rrrr'], "text"),
                       GetSQLValueString($_POST['h'], "text"));

  mysql_select_db($database_ldo, $ldo);
  $Result1 = mysql_query($insertSQL, $ldo) or die(mysql_error());
}
?>
<!doctype html>
<html>
<head>
<meta charset="windows-874">
<title>Untitled Document</title>
</head>

<body>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
  <table align="center">
    <tr valign="baseline">
      <td nowrap align="right">No.:</td>
      <td><input type="text" name="No" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Rrrr:</td>
      <td><input type="text" name="rrrr" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">H:</td>
      <td><input type="text" name="h" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td><input type="submit" value="Insert record"></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>
</body>
</html>


Mos Kritsada 101.51.127.xxx 17-04-2015 10:23
 ความคิดเห็นที่ 3
ในตอน insert ลองลบฟิลด์ที่กำหนด auto_increment ออกดู เพราะถึงเราไม่ส่งค่าเข้าไป ค่าน่าจะเพิ่มเองอัตโนมัติ


ninenik 171.96.13.xxx 17-04-2015
1






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