Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ขอความช่วยเหลือเรื่องการจัดตารางหน่อยค่ะ <table>....</table>



 

ขอความช่วยเหลือเรื่องการจัดตารางหน่อยค่ะ <table>....</table>

 



Topic : 103921



โพสกระทู้ ( 132 )
บทความ ( 0 )



สถานะออฟไลน์
Twitter Facebook



ตอนแรกเป็นแบบนี้

รูป

แต่ว่าอยากได้แบบนี้ค่ะ

รูป

คือลองจัดดูแล้ว... แต่จัดไปจัดมา มันเละมากเลยค่ะ T^T

ขอบคุณค่ะ ^^

Code (PHP)
<?php require_once('Connections/myconnection.php');
include("session.php");
include("header.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_myconnection, $myconnection);
$query_Recordset1 = "SELECT service_fix FROM service";
$Recordset1 = mysql_query($query_Recordset1, $myconnection) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!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>

<body>
<center> 
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>
  <h3>รายงานสรุปการแจ้งซ่อมประจำเดือน
  </h3>
  <p>&nbsp;</p>
  <form name="frmdata" method="post" action="month_report.php" >
              <p>ค้นหา :
                <select name="Month" id="Month">
                    <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>
                <select name="Year" id="Year">
                  <?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>
                <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>
              <input type="submit" name="Submit" value="ค้นหา" />
              </p>
              
  </form>
          <?php 
		  
		  $arr_th_month = array("มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม");
		  $arr_service_data = array();
		  
		  $str_service_condition = "";
		  
		  if(strlen($_POST["ctm_fix"]) > 0)
		  {
			  $str_service_condition .=  "where service_id = " . GetSQLValueString($_POST["ctm_fix"],"text") . "";
		  }
		  
		  $sql = "SELECT * FROM service " . $str_service_condition;
		  //echo  $sql;
		  $rs_service = mysql_query($sql);
		  while($row_service = mysql_fetch_array($rs_service))
		  {
			  $arr_data = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);

			  $str_condition = "";

			   if(strlen($_POST["Year"]) > 0)
			   {
				  $str_condition .= "year(ctm_date) = '" . GetSQLValueString($_POST["Year"],"int") . "'";
			   }
			   else
			   {
				  $_POST["Year"] = date("Y");
				  $str_condition .= "year(ctm_date) = '" . date("Y") . "'";
			   }
			   
			   if(strlen($_POST["Month"]) > 0)
			   {
				  $str_condition .= " and month(ctm_date) = '" . GetSQLValueString($_POST["Month"],"int") . "'";
			   }
			   else
			   {
				  $_POST["Month"] = date("m");
				  $str_condition .= " and month(ctm_date) = '" . date("m") . "'";
			   }
			   
				$str_condition .= ((strlen($str_condition) > 0)?" and ":"") . "ctm_fix = " . GetSQLValueString($row_service["service_id"],"text") . "";
				$str_condition .= ((strlen($str_condition) > 0)?" and ":"") . "User_add = " . GetSQLValueString($_SESSION["UserID"],"text") . "";
			   
			    $sql="SELECT * FROM data_customers " . ((strlen($str_condition) > 0)?"where ":"") . $str_condition;

				//echo $sql;
		
				$rs = mysql_query($sql);
				while($row = mysql_fetch_array($rs))
				{
				   $int_month = intval(date("d",strtotime($row['ctm_date'])));
				   $arr_data[$int_month - 1] = $arr_data[$int_month - 1]+1;
				} 
				
				$arr_service['service_id'] = $row_service["service_id"];
				$arr_service['service_fix'] = $row_service["service_fix"];
				$arr_service['graph_data'] = $arr_data;

				$arr_service_data[] = $arr_service;

		  }
		  
		  //echo "<br/><br/>";
		  //print_r($arr_service_data);

		  ?>
          
           <?php $int_showday = date("t",strtotime($_POST['Year'] . "-" . $_POST['Month'] . "-" . "-1")); ?>
          
          <center><table align="center"><tr><td>
        
          <?php for($int_ser_index = 0;$int_ser_index < count($arr_service_data);$int_ser_index++) { ?>
              <div style="float:left; margin:10px"><table border="1">
              <?php for($int_index = 0;$int_index <  $int_showday;$int_index++) { ?>
               <tr>
                    <td><?php echo $int_index + 1; ?></td>
                    <td><?php echo $arr_service_data[$int_ser_index]['graph_data'][$int_index]; ?></td>
                </tr>
              <?php } ?>
              </table></div>
          <?php } ?>
          <div style="clear:both"></div>
  </td></tr></table></center>
          
          <div id="datachart" style="height: 250px;"></div>

  </p>
</center>

    <link rel="stylesheet" href="vendors/morris/morris.css">
    <script src="vendors/jquery-1.9.1.min.js"></script>
    <script src="vendors/raphael-min.js"></script>
    <script src="vendors/morris/morris.min.js"></script>
    <script>
	  $(function() {
	  
	        //Test Chart1
			Morris.Bar({
			  element: 'datachart',
			  data: [
			    <?php for($int_index = 0;$int_index < $int_showday;$int_index++) { ?>
				  { y: '<?php echo ($int_index + 1) ?>'<?php for($int_ser_index = 0;$int_ser_index < count($arr_service_data);$int_ser_index++) { ?>,s<?php echo $arr_service_data[$int_ser_index]['service_id'] ?>: <?php echo $arr_service_data[$int_ser_index]['graph_data'][$int_index] ?><?php } ?>}<?php echo(($int_index == $int_showday - 1))?"":"," ?>
				<?php } ?>
			  ],
			  xkey: 'y',
			  ykeys: [
			  <?php for($int_ser_index = 0;$int_ser_index < count($arr_service_data);$int_ser_index++) { ?>
			  <?php echo (($int_ser_index == 0))?"":"," ?>'s<?php echo $arr_service_data[$int_ser_index]['service_id'] ?>'
			  <?php } ?>
			  ],
			  labels: [
			  <?php for($int_ser_index = 0;$int_ser_index < count($arr_service_data);$int_ser_index++) { ?>
			  <?php echo (($int_ser_index == 0))?"":"," ?>'<?php echo $arr_service_data[$int_ser_index]['service_fix'] ?>'
			  <?php } ?>
			  ]
			});
	
	  });
			
	</script>


</body>
</html>
<?php
mysql_free_result($Recordset1);
?>





Tag : PHP, MySQL









ประวัติการแก้ไข
2013-12-23 20:13:06
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-12-23 20:12:37 By : aorplus View : 732 Reply : 6
 

 

No. 1



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


ง่ายมากไล่ tr td แนะนำให้เปิดกระดาษเปล่าขึ้นมาใหม่เพื่อทำความเข้าใจครับ


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<table width="100%" border="1">
  <tr>
    <td rowspan="2">CASE X</td>
    <td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td>
    <td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td><td>18</td><td>19</td><td>20</td>
    <td>21</td><td>22</td><td>23</td><td>24</td><td>25</td><td>26</td><td>27</td><td>28</td>
    <td>29</td><td>30</td><td>31</td>  
  </tr>
  <tr>
  <?
  $i=1;
  while ($i<=31) {   //SQL ลงที่นี่โดยนำ $i ไปแทนค่าวันที่ และนำไปคิวรี่ในขั้นตอนต่อๆไป
  ?>
    <td> <? echo "$i" ?></td>
  <?
  $i++;
  }
  ?>  
  </tr>
</table>








แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-23 21:19:43 By : meannerss
 


 

No. 2



โพสกระทู้ ( 132 )
บทความ ( 0 )



สถานะออฟไลน์
Twitter Facebook

ขอบคุณค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-23 21:42:13 By : aorplus
 

 

No. 3



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


แหม. . ไม่ได้เข้ามานาน ระบบยังไม่เสร็จอีกเหรอครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-23 21:44:31 By : meannerss
 


 

No. 4



โพสกระทู้ ( 132 )
บทความ ( 0 )



สถานะออฟไลน์
Twitter Facebook

ตอบความคิดเห็นที่ : 3 เขียนโดย : meannerss เมื่อวันที่ 2013-12-23 21:44:31
รายละเอียดของการตอบ ::
ยังเลยค่ะ T^T (ยาวนาน 5555)

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-23 21:50:48 By : aorplus
 


 

No. 5



โพสกระทู้ ( 3,843 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์
Twitter Facebook

อีกทางเลือกครับ
tb
Code (PHP)
<?php
$days = 30;

$tb_header='<td>วันที่</td>';
$tb_data='<td>จำนวนครั้ง</td>';

$table='<table border="1"><tr><td rowspan="2" valign="middle">Case1</td>';

for($i=0;$i<$days;$i++){
$tb_header .='<td>'.($i+1).'</td>';
$tb_data .='<td></td>';
}
$table = $table.$tb_header.'</tr><tr>'.$tb_data.'</tr>';

echo $table;
?>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-23 22:14:29 By : mangkunzo
 


 

No. 6



โพสกระทู้ ( 132 )
บทความ ( 0 )



สถานะออฟไลน์
Twitter Facebook

ตอบความคิดเห็นที่ : 5 เขียนโดย : mangkunzo เมื่อวันที่ 2013-12-23 22:14:29
รายละเอียดของการตอบ ::
ขอบคุณค่ะ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-23 22:21:55 By : aorplus
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ขอความช่วยเหลือเรื่องการจัดตารางหน่อยค่ะ <table>....</table>
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่