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 > สืบเนื่องจากระทู้ก่อนครับ เรื่อง multiple checkbox



 

สืบเนื่องจากระทู้ก่อนครับ เรื่อง multiple checkbox

 



Topic : 105410



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



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




จากภาพนะครับ ถ้าเลือกตัวเดียวจากแต่ละหัวข้อไม่มีปัญหาครับทำได้แล้ว แต่ถ้าหัวข้อนั้น ๆ เราเลือก 2 ตัวขึ้นไป จะเกิดปัญหาคือ เมื่อไปอีกหน้านึงมันจะจำค่าสุดท้ายที่เราได้เลือกจากหน้านี้ ไม่จำทั้งหมดที่เลือก เช่น ถ้าเราเลือก checkbox ทั้ง 2 มันก็จะจำแค่ตัวที่ 2
ก

code checkbox
Code (PHP)
<input name="chkSel[]" type="checkbox" value = "<?php echo $objResult["activity_id"]."|".$objResult["name"]."|".$objResult["description"]."|".$objResult["activity_level"]."|".$objResult["config_type"]; ?>">


code เมื่อเรียกใช้อีกหน้า
Code (PHP)
<?php 
		 foreach($_POST["chkSel"] as $line){
      	 $item = explode("|" , $line);   // $item[0] , $item[1] ,.....
		 }
		?>




Tag : PHP, MySQL, HTML/CSS, JavaScript, Ajax, jQuery







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-02-03 21:17:02 By : littlebeer View : 829 Reply : 6
 

 

No. 1



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

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

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


ลองคลิ๊กเมาส์ขวาที่หน้าฟอร์ม แล้วเลือก view source (เรียกดูต้นฉบับ) แล้วเอาโค้ดมาลงให้ดูหน่อยครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-03 22:22:06 By : sakuraei
 


 

No. 2



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



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


Code (PHP)
<html>
<head>
<title>Admin MOS Template</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Copyright" content="arirusmanto.com">
<meta name="description" content="Admin MOS Template">
<meta name="keywords" content="Admin Page">
<meta name="author" content="Ari Rusmanto">
<meta name="language" content="Bahasa Indonesia">

<link rel="shortcut icon" href="stylesheet/img/devil-icon.png"> <!--Pemanggilan gambar favicon-->
<link rel="stylesheet" type="text/css" href="mos-css/mos-style.css"> <!--pemanggilan file css-->
</head>

<body>
<div id="header">
	<div class="inHeader">
		<div class="mosAdmin">
		สวัสดี คุณ Administrator<br>
		<a href=javascript:if(confirm('ยืนยันการออกจากระบบ')==true){window.location='logout.php';}>ออกจากระบบ</a> | <a href="edit_profile.php">แก้ไขข้อมูลส่วนตัว</a>
		</div>
	<div class="clear"></div>
	</div>
</div>

<div id="wrapper">
	<div id="leftBar">
	<ul>
		<li><a href="index.php">หน้าแรก</a></li>
		<li><a href="tabel.php">เรียกใช้ข้อมูล</a></li>
		<li><a href="">โมเดลข้อมูล</a></li>
	</ul>
	</div>
	<div id="rightContent">
	<h3>เรียกดูข้อมูล</h3>
	<form name ="Frm" method="POST" action="form.php">
     <input type="date" required> ถึง <input type="date" required> &nbsp;&nbsp;<font color="#FF0000">เลือกช่วงวันที่ในการแสดงข้อมูล</font>
	<div class="informasi">
	ข้อมูลด้านการบริหารจัดการ <br>
    <img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/> การกำหนดคุณค่า <img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/> กิจกรรม
	</div>
          <table class="data">
			<tr class="data">
				<th class="data" width="30">No</th>
				<th class="data">ชื่อ</th>
				<th class="data">คำอธิบาย</th>
				<th class="data" width="75">เลือกข้อมูล</th>
			</tr>
				<tr class="data">
				<td class="data" width="30">1</td>
				<td class="data">ddddd</td>
				<td class="data">gggggg</td>
				<td class="data" width="75">
				<center>
				<input name="chkSel[]" type="checkbox" value = "1|ddddd|gggggg|ddd|ddd">
				</center>
				</td>
			</tr>
      			<tr class="data">
				<td class="data" width="30">2</td>
				<td class="data">khgjgh</td>
				<td class="data">frererr</td>
				<td class="data" width="75">
				<center>
				<input name="chkSel[]" type="checkbox" value = "2|khgjgh|frererr|23|dfsf">
				</center>
				</td>
			</tr>
      	  </table>
     
    <div class="informasi">
	ข้อมูลด้านการบริหารจัดการ <br>
    <img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/> หุ้นส่วน <img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/> ข้อตกลง</div>
     	<table class="data">
			<tr class="data">
				<th class="data" width="30">No</th>
				<th width="72" class="data">ชื่อ</th>
				<th width="82" class="data">คำอธิบาย</th>
				<th width="80" class="data">เหตุผล</th>
                <th class="data">กลยุทธ์ที่สำคัญ</th>
				<th class="data" width="100">ระดับการแข่งขัน</th>
                <th class="data" width="105">ระดับการรวมกลุ่ม</th>
                <th class="data" width="97">การทดแทน</th>
                <th class="data" width="75">เลือกข้อมูล</th>
	  </tr>
      			<tr class="data">
				<td class="data" width="30">665</td>
				<td class="data">asdfads  </td>
				<td class="data">adsfad  </td>
				<td class="data">asdfa  </td>
				<td class="data" width="92">1</td>
                <td class="data" width="100">2</td>
                <td class="data">3</td>
                <td class="data" width="97">4</td>
                <td class="data" width="75">
				<center>
				<input name="chkSel1[]" type="checkbox" value = "665|asdfads  |adsfad  |asdfa  |1|2|3|4">
				</center>
				</td>
			</tr>
            			<tr class="data">
				<td class="data" width="30">454</td>
				<td class="data">ปลาทู</td>
				<td class="data">ปลาทูเน่า</td>
				<td class="data">เน่าเพราะไม่ได้แช่เย็น</td>
				<td class="data" width="92">0</td>
                <td class="data" width="100">2</td>
                <td class="data">3</td>
                <td class="data" width="97">0</td>
                <td class="data" width="75">
				<center>
				<input name="chkSel1[]" type="checkbox" value = "454|ปลาทู|ปลาทูเน่า|เน่าเพราะไม่ได้แช่เย็น|0|2|3|0">
				</center>
				</td>
			</tr>
            	  </table>
      
    <div class="informasi">
	ข้อมูลด้านการบริหารจัดการ <br>
    <img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/>ความสามารถของธุรกิจ<img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/> ทรัพยากร	</div>
     	<table class="data">
			<tr class="data">
				<th class="data" width="30">No</th>
				<th class="data">ชื่อทรัพยากร</th>
				<th class="data">คำอธิบาย</th>
				<th class="data">ประเภททรัพยากร</th>
				<th class="data" width="75">เลือกข้อมูล</th>
			</tr>
             			<tr class="data">
				<td class="data" width="30">566</td>
				<td class="data">sdfa     </td>
				<td class="data">asdfasdf     </td>
				<td class="data">รูปธรรม </td>
				<td class="data" width="75">
				<center>
				<input name="chkSel2[]" type="checkbox" value = "566|sdfa     |asdfasdf     |รูปธรรม ">
				</center>
				</td>
			</tr>
             			<tr class="data">
				<td class="data" width="30">444</td>
				<td class="data">ปลาทู  </td>
				<td class="data">ปลาทูนำเข้าจากญี่ปุ่น  </td>
				<td class="data">นามธรรม </td>
				<td class="data" width="75">
				<center>
				<input name="chkSel2[]" type="checkbox" value = "444|ปลาทู  |ปลาทูนำเข้าจากญี่ปุ่น  |นามธรรม ">
				</center>
				</td>
			</tr>
             			<tr class="data">
				<td class="data" width="30">999</td>
				<td class="data">ต้นไม้ </td>
				<td class="data">ต้นไม้หลายต้น </td>
				<td class="data">นามธรรม </td>
				<td class="data" width="75">
				<center>
				<input name="chkSel2[]" type="checkbox" value = "999|ต้นไม้ |ต้นไม้หลายต้น |นามธรรม ">
				</center>
				</td>
			</tr>
             	  </table>  
	<div class="gagal">
	ข้อมูลด้านลูกค้า <br>
    <img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/> ลูกค้าเป้าหมาย <img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/> เกณฑ์
	</div>
    	<table class="data">
			<tr class="data">
				<th class="data" width="30">No</th>
				<th class="data">ชื่อ</th>
				<th class="data">คำอธิบาย</th>
				<th class="data" width="75">เลือกข้อมูล</th>
			</tr>
             			<tr class="data">
			  <td class="data" width="30">111</td>
				<td class="data">qwer</td>
				<td class="data">asdfadf</td>
				<td class="data" width="75">
				<center>
				<input name="chkSel3[]" type="checkbox" value = "111|qwer|asdfadf">
				</center>
				</td>
			</tr>
            	  </table>  
    
    <div class="gagal">
	ข้อมูลด้านลูกค้า <br>
    <img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/> ช่องทางการจัดจำหน่าย <img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/> ธุรกิจกับลูกค้า
	</div>
    	<table class="data">
			<tr class="data">
				<th class="data" width="30">No</th>
				<th class="data">ชื่อ</th>
				<th class="data">คำอธิบาย</th>
				<th class="data">เหตุผล</th>
				<th class="data" width="75">ระดับคุณค่า</th>
                <th class="data" width="75">ระดับราคา</th>
                <th class="data" width="75">วงจรชีวิตผลิตภัณฑ์</th>
                <th class="data" width="75">วงจรการซื้อของลูกค้า</th>
                <th class="data" width="75">เลือกข้อมูล</th>
			</tr>
             			<tr class="data">
				<td class="data" width="30">111</td>
				<td class="data">น้ำปลา </td>
				<td class="data">น้ำปลาแท้จากปลาทู555 </td>
				<td class="data">เป็นปลาทูที่นำเข้าจากประเทศญี่ปุ่นเลยนะ </td>
				<td class="data">Innovative </td>
                <td class="data">Economy </td>
                <td class="data">Use </td>
                <td class="data">Evaluation </td>
                <td class="data">
                <center>
				<input name="chkSel4[]" type="checkbox" value = "111|น้ำปลา |น้ำปลาแท้จากปลาทู555 |เป็นปลาทูที่นำเข้าจากประเทศญี่ปุ่นเลยนะ |Innovative |Economy |Use |Evaluation ">
				</center>
                </td>
			</tr>
            	  </table>  
    
    <div class="gagal">
	ข้อมูลด้านลูกค้า <br>
    <img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/> ความสัมพันธ์กับลูกค้า <img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/> กลไกสร้างความสัมพันธ์
	</div>
    	<table class="data">
			<tr class="data">
				<th class="data" width="30">No</th>
				<th class="data">ชื่อ</th>
				<th class="data">คำอธิบาย</th>
				<th class="data">เหตุผล</th>
				<th class="data" width="75">ระดับคุณค่า</th>
                <th class="data" width="75">ระดับราคา</th>
                <th class="data" width="75">วงจรชีวิตผลิตภัณฑ์</th>
                <th class="data" width="75">วงจรการซื้อของลูกค้า</th>
                <th class="data" width="75">การสร้างความสัมพันธ์</th>
                <th class="data" width="75">เลือกข้อมูล</th>
			</tr>
            			<tr class="data">
				<td class="data" width="30">111</td>
				<td class="data">aasdfff </td>
				<td class="data">asdffff </td>
				<td class="data">asdffffa </td>
				<td class="data">Excellence </td>
                <td class="data">Free </td>
                <td class="data">Use </td>
                <td class="data">After Sales </td>
                <td class="data">ตราสินค้า </td>
                <td class="data">
                <center>
				<input name="chkSel5[]" type="checkbox" value = "111|aasdfff |asdffff |asdffffa |Excellence |Free |Use |After Sales |ตราสินค้า ">
				</center>
                </td>
			</tr>
            	  </table>  
          
	<div class="product">
    ข้อมูลด้านสินค้า <br>
	<img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/> การกำหนดคุณค่าผลิตภัณฑ์ <img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/> สิ่งที่นำเสนอ</div>
     		<table class="data">
			<tr class="data">
				<th class="data" width="30">No</th>
				<th class="data">ชื่อ</th>
				<th class="data">คำอธิบาย</th>
				<th class="data">เหตุผล</th>
                <th class="data">ระดับคุณค่า</th>
                <th class="data">ระดับราคา</th>
                <th class="data">วงจรชีวิตผลิตภัณฑ์</th>
				<th class="data" width="75">เลือกข้อมูล</th>
			</tr>
               			<tr class="data">
				<td class="data" width="30">444</td>
				<td class="data">รองเท้า  </td>
				<td class="data">รองเท้าหนัง  </td>
				<td class="data">หนังเสือ  </td>
                <td class="data">Me-too </td>
                <td class="data">Economy </td>
                <td class="data">Creation </td>
				<td class="data" width="75">
				<center>
				<input name="chkSel6[]" type="checkbox" value = "444|รองเท้า  |รองเท้าหนัง  |หนังเสือ  |Me-too |Economy |Creation ">
				</center>
				</td>
			</tr>
            		</table>
        
        <div class="sukses">ข้อมูลด้านการดำเนินงาน<br>
	<img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/> โครงสร้างค่าใช้จ่าย <img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/> รายงานผลบัญชี </div>
    		<table class="data">
			<tr class="data">
				<th class="data" width="30">No</th>
				<th class="data">ชื่อกิจกรรม</th>
				<th class="data">คำอธิบาย</th>
				<th class="data">ผลรวม</th>
                <th class="data">กำไร/ผลประโยชน์</th>
				<th class="data" width="75">เลือกข้อมูล</th>
			</tr>
             			<tr class="data">
				<td class="data" width="30">111</td>
				<td class="data">กาแฟสด </td>
				<td class="data">ปลาท่องโก๋ตัวใหญ่มาก </td>
				<td class="data">3453467</td>
                <td class="data">100000</td>
				<td class="data" width="75">
				<center>
				<input name="chkSel7[]" type="checkbox" value = "111|กาแฟสด |ปลาท่องโก๋ตัวใหญ่มาก |3453467|100000">
				</center>
				</td>
			</tr>
            			<tr class="data">
				<td class="data" width="30">0</td>
				<td class="data"></td>
				<td class="data"></td>
				<td class="data">0</td>
                <td class="data">0</td>
				<td class="data" width="75">
				<center>
				<input name="chkSel7[]" type="checkbox" value = "0|||0|0">
				</center>
				</td>
			</tr>
            		</table>
        
        <div class="sukses">ข้อมูลด้านการดำเนินงาน<br>
	<img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/>  รายรับ-รายจ่าย <img src="mos-css/img/bullet1.png" width="14" height="14"  alt=""/> รูปแบบรายรับ รายจ่ายและการกำหนดราคา </div>
    		<table class="data">
			<tr class="data">
				<th class="data" width="30">No</th>
				<th class="data">ชื่อกิจกรรม</th>
				<th class="data">คำอธิบาย</th>
				<th class="data">ประเภทกระแสรายได้</th>
                <th class="data">อัตราร้อยละ</th>
                <th class="data">วิธีการกำหนดราคา</th>
				<th class="data" width="75">เลือกข้อมูล</th>
			</tr>
            			<tr class="data">
				<td class="data" width="30">111</td>
				<td class="data">น้ำปลา </td>
				<td class="data">น้ำปลาอย่างดี </td>
				<td class="data">การปล่อยสินเชื่อ </td>
                <td class="data">345555</td>
                <td class="data">คงที่ </td>
				<td class="data" width="75">
				<center>
				<input name="chkSel8[]" type="checkbox" value = "111|น้ำปลา |น้ำปลาอย่างดี |การปล่อยสินเชื่อ |345555|คงที่ ">
				</center>
				</td>
			</tr>
            		</table>
        <center>
      	<input type="submit" value="ตกลง">&nbsp;&nbsp;<input type="reset">
      	</center>
        </form>
	</div>
<div class="clear"></div>
<div id="footer">
	&copy; 2012 MOS css template | Beer Berry | design BMC<br>
	redesign <a href="#">BMC </a> | Rajamangala University of Technology </div>
</div>
<br />
<b>Warning</b>:  mysql_close() expects parameter 1 to be resource, null given in <b>C:\xampp\htdocs\mos_admin\tabel.php</b> on line <b>394</b><br />
</body>
</html>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-03 22:40:44 By : littlebeer
 

 

No. 3



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

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

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


แล้วตอนนำไปใช้ โค้ดเป็อย่างไรครับ

เท่าที่ดูจากโค้ดที่วางมาก็ดูเป็นปกติดีครับ

Code (PHP)
if(isset($_POST["chkSel"])){
   foreach($_POST["chkSel"] as $line){
     $items = explode("|",$line);
     // $items[0] = "1"  $items[1] = "ddddd"  $items[2] = "gggggg"  $items[3] = "ddd" $items[4] = "ddd"
   }
}

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-03 22:58:00 By : sakuraei
 


 

No. 4



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



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


อย่างที่บอกอะครับว่า ถ้าเราเลือก checkbox 2 ขึ้นไปในหัวข้อนั้น ๆ มันจะเลือกแค่ตัวสุดท้ายมาแสดงอีกหน้า

หลังจาก foreach แล้วนะครับ
Code (PHP)
<td class="data" width="38"><?php echo $item[0] ?></td>
				<td class="data"><?php echo $item[1] ?></td>
				<td class="data"><?php echo $item[2] ?></td>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-03 23:30:49 By : littlebeer
 


 

No. 5



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

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

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


การนำข้อมูลมาใช้ต้องอยู่ภายในลูปของ foreach ครับ
if(isset($_POST["chkSel"])){
   foreach($_POST["chkSel"] as $line){
     $item = explode("|",$line);
     echo "<tr><td class='data' width='38'>{$item[0]}</td>",
              "<td class='data'>{$item[1]}</td>",
              "<td class='data'>{$item[2]}</td></tr>\n";
   }
}



แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-04 00:02:31 By : sakuraei
 


 

No. 6



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



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


ได้แล้ววครับ ขอบคุณมากครับบบ :)
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-04 10:17:45 By : littlebeer
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สืบเนื่องจากระทู้ก่อนครับ เรื่อง multiple checkbox
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 03
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 อัตราราคา คลิกที่นี่