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,028

HOME > PHP > PHP Forum > การดึงข้อมูล จาก SQL มาอยู่ใน LIST Menu แบบลูปออกมาเรื่อยๆ ครับ ตอนนี้ได้แค่ ดึงตัวเดียว



 

การดึงข้อมูล จาก SQL มาอยู่ใน LIST Menu แบบลูปออกมาเรื่อยๆ ครับ ตอนนี้ได้แค่ ดึงตัวเดียว

 



Topic : 075588



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



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




Code (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>::Network Care Management Systems::</title>
<style type="text/css">
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
.Head {
	text-align: center;
	font-size: 36px;
	color: #FC0;
	font-weight: bold;
	font-style: italic;
}
.Menuadmin {
	text-align: center;
	font-weight: bold;
	color: #333;
}
headtable {
	font-size: 24px;
}
headtable {
	font-size: 24px;
}
#form1 table tr .Head_Table2 {
	font-weight: bold;
	font-size: 36px;
	color: #333;
}
red char {
	color: #F00;
}
red char {
	color: #F00;
}
.red {
	color: #F00;
	font-weight: bold;
}
#form1 table {
	font-weight: bold;
}
</style>
</head>

<body>
<table width="937" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="937">&nbsp;</td>
  </tr>
  <tr>
    <td><table width="937" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="267" height="70"><img src="img/home_logo1.gif" width="267" height="70" /></td>
        <td>&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="937" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="267" height="74"><img src="img/home_logo2.gif" width="267" height="74" /></td>
        <td height="74" bgcolor="#26C1FB" class="Head">Admin Management system</td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td height="502"><form id="form1" name="form1" method="post" action="admin_service_save.php">
      <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td colspan="2" align="center" bgcolor="#3366CC" class="Head_Table2">Service</td>
        </tr>
        <tr>
          <td width="106" bgcolor="#3366CC">ServiceName</td>
          <td width="831" bgcolor="#3366CC"><label for="nametxt"></label>
            <input type="text" name="nametxt" id="nametxt" /></td>
        </tr>
        <tr>
          <td bgcolor="#3366CC">ServicePrice</td>
          <td bgcolor="#3366CC"><input type="text" name="pricetxt" id="pricetxt" /></td>
        </tr>
        <tr>
          <td bgcolor="#3366CC"> SeviceType </td>
          <td bgcolor="#3366CC"><label for="SeviceType_ID"></label>
          <? 
		  //ใช้ Listbox ดึงข้อมูลออกจาก SQL
$host="127.0.0.1";
$root="root";
$rootpw="1234";
$dbname="networkcare";

mysql_connect($host,$root,$rootpw) or die("Not connect Host");
mysql_query("SET character_set_results=tis620");
mysql_query("SET character_set_client=tis620");
mysql_query("SET character_set_connection=tis620");
mysql_select_db($dbname) or die("No connect Database");
	///******************/////
	
	/// เลือกข้อมูล////
		  $sql=" select SeviceType_Name FROM service_type";
		  
		  $result = mysql_query($sql);
		$data = mysql_fetch_array($result)
		 ?>
          <label for="TypeName"></label>
          <select name="TypeName" id="TypeName">
            <option value="<?=$data["SeviceType_Name"] ?>"><? echo $data["SeviceType_Name"]?></option>
          </select>
          <label for="select"></label></td>
          
        </tr>
        <tr>
          <td bgcolor="#3366CC">&nbsp;</td>
          <td bgcolor="#3366CC">&nbsp;</td>
        </tr>
        <tr>
          <td bgcolor="#3366CC">&nbsp;</td>
          <td bgcolor="#3366CC"><input type="submit" name="button" id="button" value="Submit" />
            <input type="reset" name="button2" id="button2" value="Reset" /></td>
        </tr>
      </table>
    </form>   </td>
  </tr>
  <tr>
    <td><table width="937" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="937" height="70"><img src="img/home_linebottonpage.gif" width="937" height="70" /></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>



ตอนนี้ดึงออกมาได้แล้ว แต่ ออกมาตัว เดียว เขียน Loop ตรงไหนดีครับ ให้ มันลูป ออกมาจนหมด

ทำแบบในเครดิต http://teerapuch.wordpress.com/2011/05/04/%E0%B9%83%E0%B8%8A%E0%B9%89-listbox-%E0%B9%81%E0%B8%AA%E0%B8%94%E0%B8%87%E0%B8%82%E0%B9%89%E0%B8%AD%E0%B8%A1%E0%B8%B9%E0%B8%A5%E0%B8%97%E0%B8%B5%E0%B9%88%E0%B8%94%E0%B8%B6%E0%B8%87%E0%B8%AD%E0%B8%AD/ แล้วโค้ดไม่ผ่านครับ



Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-03-15 14:17:25 By : BigGulp[32oz] View : 1346 Reply : 2
 

 

No. 1



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

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

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

ข้อมูลมีหลาย rows ต้องเอาเข้า ลูปในการ list rows ออกมาทั้งหมดครับ

Code (PHP)
          <select name="TypeName" id="TypeName">
          <?
           $sql=" select SeviceType_Name FROM service_type";		  
	   $result = mysql_query($sql);
           

           while($data = mysql_fetch_array($result))
           {
            echo " <option value=".$data["SeviceType_Name"].">".$data["SeviceType_Name"]."</option>";
           }
          ?>
           
          </select>







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-03-15 14:32:26 By : mangkunzo
 


 

No. 2



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



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


ขอบคุณครับ คุณ mangkunzo ขอนำไปลอง ได้ผลยังไงจะแจ้งให้ทราบครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-03-15 14:50:01 By : BigGulp[32oz]
 

   

ค้นหาข้อมูล


   
 

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