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 > หนูเอาตัวอย่างจากกระทู้ในนี้ของพี่วิน มาลองทำดูคะ แล้วหนูใช้วิธีการ Search จาก Code แล้วให้ข้อมูลมัน show ตาม Text box แล้วอยากให้ group มัน Show เป็น list box โดย อิงจาก Code ที่เรา Search



 

หนูเอาตัวอย่างจากกระทู้ในนี้ของพี่วิน มาลองทำดูคะ แล้วหนูใช้วิธีการ Search จาก Code แล้วให้ข้อมูลมัน show ตาม Text box แล้วอยากให้ group มัน Show เป็น list box โดย อิงจาก Code ที่เรา Search

 



Topic : 106741

Guest




หนูเอาตัวอย่างจากกระทู้ในนี้ของพี่วิน มาลองทำดูคะ แล้วหนูใช้วิธีการ Search จาก Code แล้วให้ข้อมูลมัน show ตาม Text box แล้วอยากให้ group มัน Show เป็น list box โดย อิงจาก Code ที่เรา Search นะคะ มาเป็น list menu ให้เราเลือกตรงที่สี่เหลี่ยมสีแดงที่หนูใส่ไว้ ไม่ทราบใครพอจะมีวิธีแนะนำหนูบ้างคะ
test



Tag : PHP, MySQL







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-03-10 10:33:40 By : guest View : 1039 Reply : 29
 

 

No. 1



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



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

บ่องตง งงกับคำถามครับ มโนไม่ออก






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 10:58:57 By : itpcc
 


 

No. 2



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



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


ไม่รู้เข้าใจถูกแบบนี้หรือเปล่า งง กับคำถามเหมือนกันครับ

Code (PHP)
<select name="test" id="test">
                      <option value="0"<? if($data[group ] == '$group'){?> selected="selected" <? }?>>show</option>
			    <option value="1"<? if($data[group ] == '$group'){?> selected="selected" <? }?>>show </option>
			    <option value="2"<? if($data[group ] == '$group'){?> selected="selected" <? }?>>show </option>
                <option value="3"<? if($data[group ] == '$group'){?> selected="selected" <? }?>>show </option>
			    <option value="4"<? if($data[group ] == '$group'){?> selected="selected" <? }?>>show </option>
			    <option value="5"<? if($data[group ] == '$group'){?> selected="selected" <? }?>>show </option>
                <option value="5"<? if($data[group ] == '$group'){?> selected="selected" <? }?>>show </option>
                    </select>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 11:07:29 By : wita
 

 

No. 3



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



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

เก็บ group ใน database ยังไงครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 11:09:11 By : kerb
 


 

No. 4

Guest


เวรกรรมของหนู ตรงหน้า Interface เนี่ยคะ ถ้าเราค้นหาจากรหัสนะคะ พอกดปุ่ม Search จะมีหน้า pop up ให้ค้นหานะคะ พอค้นหาจากรหัสตามที่ต้องการแล้วเลือก รหัสนั้นมาแล้ว หนูกะจะได้ ชื่อนามสกุล แผนกมาคะ แต่ว่าข้างในนั้นมันยังมี group หลาย ๆ อัน เช่น รหัส 2346 มี group A, Group B ก็เลยอยากให้ group A, Group B show ที่ Drop down list นะคะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 11:11:30 By : guest
 


 

No. 5



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



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

ตอบความคิดเห็นที่ : 4 เขียนโดย : guest เมื่อวันที่ 2014-03-10 11:11:30
รายละเอียดของการตอบ ::
ใน dropDown มี option อยู่แล้วยัง?

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 11:19:08 By : itpcc
 


 

No. 6

Guest


พี่ Guide หนูเก็บผูกไว้กะ Code ของ User นะคะ ตอนนี้ หนู ค้นหาแล้วข้อมูลส่งค่ามาทุกอันยกเว้น Group มันไม่ Show ใน list ให้เลือก นะคะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 11:20:45 By : guest
 


 

No. 7

Guest


Code (PHP)
<?php
include "Connect.php";

?>
<html>
<head>
<title>Data</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<?
//mysql_connect("localhost","root","root");
//mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM user where Code =  '".$_GET["Code"]."'";
$objQuery = mysql_query($strSQL);
?>
<script language="javascript">

	function CreateSelectOption(ele)
	{
		var objSelect = document.getElementById(ele);
		var Item = new Option("", ""); 
		objSelect.options[objSelect.length] = Item;
		<?
		while($objResult = mysql_fetch_array($objQuery))
		{
		?>
		var Item = new Option("<?=$objResult["groupname"];?>", "<?=$objResult["groupname"];?>"); 
		objSelect.options[objSelect.length] = Item;
		<?
		}
		?>
	}

	function CreateNewRow()
	{
		var intLine = parseInt(document.frmMain.hdnMaxLine.value);
		intLine++;
			
		var theTable = document.getElementById("tbExp");
		var newRow = theTable.insertRow(theTable.rows.length)
		newRow.id = newRow.uniqueID

		var newCell
		
		//*** Column 1 ***//
		newCell = newRow.insertCell(0);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column1_"+intLine+"\"  ID=\"Column1_"+intLine+"\" VALUE=\"\"></center>";

		//*** Column 2 ***//
		newCell = newRow.insertCell(1);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column2_"+intLine+"\" ID=\"Column2_"+intLine+"\"  VALUE=\"\"></center>";
		
		//*** Column 3 ***//
		newCell = newRow.insertCell(2);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column3_"+intLine+"\"  ID=\"Column3_"+intLine+"\" VALUE=\"\"></center>";
		
		//*** Column 4 ***//
		newCell = newRow.insertCell(3);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column4_"+intLine+"\"  ID=\"Column4_"+intLine+"\" VALUE=\"\"></center>";
		
		//*** Column 5 ***//
		newCell = newRow.insertCell(4);
		newCell.id = newCell.uniqueID;
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<center><SELECT NAME=\"Column5_"+intLine+"\" ID=\"Column5_"+intLine+"\"></SELECT></center>";

		//*** Create Option ***//
		CreateSelectOption("Column5_"+intLine)
		
		document.frmMain.hdnMaxLine.value = intLine;
	}
	
	function RemoveRow()
	{
		intLine = parseInt(document.frmMain.hdnMaxLine.value);
		if(parseInt(intLine) > 0)
		{
				theTable = document.getElementById("tbExp");				
				theTableBody = theTable.tBodies[0];
				theTableBody.deleteRow(intLine);
				intLine--;
				document.frmMain.hdnMaxLine.value = intLine;
		}	
	}	
</script>
<body>
<form name="frmMain" method="post">
	<table width="50%" border="0" align="center" action="readdata1.php" >
		<tr>
            <td width="11%"><b>Code</b></td>
            <td width="16%"><input name="Code" type="text" id="Code" size ="10" />
			<input type="BUTTON" name="btnPopup" value="Search" onclick="OpenPopup1('CodeSearch.php', 'myPopup','width=750,height=700,toolbar=0, menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0')"></td>
                <td width="11%"><b>Name</b></td>
				<td width="23%"><input name="Name" type="text" id="Name" size ="30"  style="background:#FFCC66" readonly  />
			</tr>
			<tr>
				<td width="9%"><b>Surname</b></td>
                <td width="13%"><input name="Surname" type="text" id="Surname" size ="10" />
				<td width="10%"><b>Department</b></td>
                <td width="7%"><input name="Department" type="text" id="Department" size ="25" />
		</tr>


<table width="50%" border="1" id="tbExp">
<tr>
    <td><div align="center">Column 1 </div></td>
    <td><div align="center">Column 2 </div></td>
    <td><div align="center">Column 3 </div></td>
    <td><div align="center">Column 4 </div></td>
    <td><div align="center">Column 5 </div></td>
  </tr>
</table>
</table>

<input type="hidden" name="hdnMaxLine" value="1">
<input name="btnAdd" type="button" id="btnAdd" value="+" onClick="CreateNewRow();">
<input name="btnDel" type="button" id="btnDel" value="-" onClick="RemoveRow();">
</form>
</body>
</html>


หนูมี Code แบบนี้คะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 11:28:08 By : guest
 


 

No. 8



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



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

พี่ขอดูข้อมูล ที่ query ได้หน่อยได้มั้ยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 12:54:52 By : kerb
 


 

No. 9

Guest


SELECT
`user`.ID,
`user`.`Code`,
`user`.`Name`,
`user`.Surname,
`user`.Group,
usergroup.Group_ID,
usergroup.Group_Code,
usergroup.Group_Name
FROM
`user`
LEft JOIN usergroup ON `user`.Group = usergroup.Group_Code
order by Code
อันนี้คะ ข้อมูลที่หนู Query คะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 13:55:34 By : guest
 


 

No. 10



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



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

1 user มีได้หลาย group หรอครับ อยากเห็นข้อมูลที่ได้จากการ query น่ะครับ


ประวัติการแก้ไข
2014-03-10 14:01:27
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 14:00:45 By : kerb
 


 

No. 11

Guest


ใช่คะ มีได้หลาย group คะ หนูก็เลยอยากให้มัน Show เป็น Drop down list คะ เพราะเวลา คลิก + เพิ่มข้อมูลจะให้ เลือก กรุ๊ปตรงนี้เลยคะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 14:12:21 By : guest
 


 

No. 12



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



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

ถ้า 1 คนอยากเลือก 2 group จะเลือกยังไงครับ เพราะมี dropdown อันเดียว?
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 14:14:12 By : kerb
 


 

No. 13

Guest


ก็คลิกปุ่มเครื่องหมาย + แล้วก็ใส่ข้อมูลตามต้องการแล้วก็ให้เลือกอีกกรุ๊ปคะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 14:17:56 By : guest
 


 

No. 14



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



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

เริ่มงงละ พี่ขอดูผลลัพท์ที่ query ออกมาหน่อยสิ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 14:21:54 By : kerb
 


 

No. 15

Guest


test

อันนี้ตัวอย่าง Query คะ


test

อันนี้ตัวอย่างที่หนูอยากให้มัน show kha
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 14:34:33 By : guest
 


 

No. 16



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



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

สมมติว่า จะแสดงข้อมูลของ rachan demark จะแสดงออกมากี่แถวหรอครับ 1 แถว หรือ 3 แถวตามจำนวน group
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 14:58:03 By : kerb
 


 

No. 17

Guest


จะต้อง Show group ออกมา 3 แถวคะ ตรงช่อง Pay Group คะ หนูขอบคุณพี่มากๆ คะ ตอนนี้หนูกะลังมึนมากมาย จะขอดูตอนห้าโมง กรุ๊ปยังไม่ขึ้นเลย
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 15:02:44 By : guest
 


 

No. 18



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



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

จริงๆแล้ว ผิดตั้งแต่ออกแบบตารางแล้วครับ แต่ถ้าจะดู 5 โมงคงไม่ทัน เอาแบบนี้ไปก่อนละกัน
ใช้ query แบบนี้ก่อนครับ
Code (SQL)
SELECT
`user`.`Code`,
`user`.`Name`,
`user`.Surname,
GROUP_CONCAT(`user`.`Group`),
GROUP_CONCAT(usergroup.Group_Name)
FROM
`user`
LEFT JOIN usergroup ON `user`.Group = usergroup.Group_Code
GROUP BY `user`.`Code`, `user`.`Name`, `user`.Surname
ORDER BY `user`.`Code`

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 15:20:29 By : kerb
 


 

No. 19



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



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

หรือถ้าจะแก้ต้องสร้างตารางเพิ่มอีกอัน คือ แนะนำให้เปลี่ยนชื่อ table usergroup เป็น group แล้วสร้างตาราง usergroup ขึ้นมาใหม่

ใช้เก็บ ID กับ GROUP_CODE
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 15:23:50 By : kerb
 


 

No. 20

Guest


แล้วถ้าหนู จะเปลี่ยนเป็น อ่านค่าจาก Textbox แล้วไปเช็คค่าใน Database ว่า Code นี้ มี group อะไรบ้างแล้วเอามา Show list box ทำได้ไม๊คะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 15:47:43 By : guest
 


 

No. 21



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



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

ใช้ query ที่พี่ให้ไปน่าจะง่ายกว่านะ ค่าที่ได้จะออกมาเป็น list

example


ตอนนำมาแสดงผลก็เขียนแบบนี้

Code (PHP)
<?php
$group = explode(',', $objResult['GROUP']);
$group_name = explode(',', $objResult['GROUP_NAME']);
?>
<select name="test" id="test">
<?php for($i=0;$i<count($group);$i++):?>
        <option value="<?php echo $group[$i]?>"><?php echo $group_name[$i]?></option>
<?php endfor;?>
</select>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 16:04:52 By : kerb
 


 

No. 22

Guest


แล้ว หนูจะเอาไปแทรกตรงไหนเหรอคะ

<?php
//include "Connect.php";

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>AP Direct</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link media="screen" rel="stylesheet" type="text/css" href="css/style.css" />
<link href="css/table_style.css" rel="stylesheet" type="text/css" />
<script src="js/ChangeTemplate.js" type="text/javascript"></script>
<script type="text/javascript" src="jquery/1.3.2/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/style11.css" media="screen" />
<script src="scripts/jquery-ui-1.8.custom.min.js" type="text/javascript"></script>
<script src="scripts/jquery.ui.selectmenu.js" type="text/javascript"></script>
<!-- scripts (custom) -->
<script type='text/javascript' src='jquery.autocomplete.js'></script>
<link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
<style type="text/css">

.divstyle
{
display: none;
}
</style>
</head>
<?
mysql_connect("localhost","root","root");
mysql_select_db("Test");
$strSQL = "SELECT * FROM user where Code = '".$_GET["Code"]."'";
$objQuery = mysql_query($strSQL);
?>
<script language="javascript">

function OpenPopup(intLine)
{
window.open('ReaddataTest.php?Line='+intLine,'myPopup','width=750,height=700,toolbar=0, menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');
}

function CreateSelectOption(ele)
{
var objSelect = document.getElementById(ele);
var Item = new Option("", "");
objSelect.options[objSelect.length] = Item;
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
var Item = new Option("<?=$objResult["groupname"];?>", "<?=$objResult["groupname"];?>");
objSelect.options[objSelect.length] = Item;
<?
}
?>
}

function CreateNewRow()
{
var intLine = parseInt(document.frmMain.hdnMaxLine.value);
intLine++;

var theTable = document.getElementById("tbExp");
var newRow = theTable.insertRow(theTable.rows.length)
newRow.id = newRow.uniqueID

var newCell

//*** Column 1 ***//
newCell = newRow.insertCell(0);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column1_"+intLine+"\" ID=\"Column1_"+intLine+"\" VALUE=\"\"></center>";

//*** Column 2 ***//
newCell = newRow.insertCell(1);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column2_"+intLine+"\" ID=\"Column2_"+intLine+"\" VALUE=\"\"></center>";

//*** Column 3 ***//
newCell = newRow.insertCell(2);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column3_"+intLine+"\" ID=\"Column3_"+intLine+"\" VALUE=\"\"></center>";

//*** Column 4 ***//
newCell = newRow.insertCell(3);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column4_"+intLine+"\" ID=\"Column4_"+intLine+"\" VALUE=\"\"></center>";

//*** Column 5 ***//
newCell = newRow.insertCell(4);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><SELECT NAME=\"Column5_"+intLine+"\" ID=\"Column5_"+intLine+"\"></SELECT></center>";

//*** Create Option ***//
CreateSelectOption("Column5_"+intLine)

document.frmMain.hdnMaxLine.value = intLine;
}

function RemoveRow()
{
intLine = parseInt(document.frmMain.hdnMaxLine.value);
if(parseInt(intLine) > 0)
{
theTable = document.getElementById("tbExp");
theTableBody = theTable.tBodies[0];
theTableBody.deleteRow(intLine);
intLine--;
document.frmMain.hdnMaxLine.value = intLine;
}
}
</script>
<body>
<form name="frmMain" method="post">
<table width="50%" border="0" align="left" action="ReaddataTest.php" >
<tr>
<td width="11%"><b>Code</b></td>
<td width="16%"><input name="Code" type="text" id="Code" size ="10" />
<input type="BUTTON" name="btnPopup" value="Search" onclick="OpenPopup('TestSearchData.php', 'myPopup','width=750,height=700,toolbar=0, menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0')"></td>
<td width="11%"><b>Name</b></td>
<td width="23%"><input name="Name" type="text" id="Name" size ="30" style="background:#FFCC66" readonly />
</tr>
<tr>
<td width="9%"><b>Surname</b></td>
<td width="13%"><input name="Surname" type="text" id="Surname" size ="10" />
<td width="10%"><b>Department</b></td>
<td width="7%"><input name="Department" type="text" id="Department" size ="25" />
</tr>
</table>
<table width="50%" border="1" id="tbExp">
<tr>
<td><div align="center">No</div></td>
<td><div align="center">Detail </div></td>
<td><div align="center">Price</div></td>
<td><div align="center">Total</div></td>
<td><div align="center">Pay Group</div></td>
</tr>
</table>

<input type="hidden" name="hdnMaxLine" value="1">
<input name="btnAdd" type="button" id="btnAdd" value="+" onClick="CreateNewRow();">
<input name="btnDel" type="button" id="btnDel" value="-" onClick="RemoveRow();">
</form>
</body>
</html>
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 16:16:38 By : guest
 


 

No. 23



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



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

ดึงค่าอื่นมาโชว์ครบรึยัง ? ยกเว้น GROUP
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 16:27:12 By : kerb
 


 

No. 24

Guest


ตัวข้างบนมาหมดละคะ Search แล้ว เลือกมันกะมาหมดคะ ส่วน No, Detail, Price, Total คีย์เข้าปกติคะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 16:36:13 By : guest
 


 

No. 25



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



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

พี่ยังไม่เห็นมี code เกี่ยวกับ search เลยอะงง
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 16:41:39 By : kerb
 


 

No. 26

Guest


<table width="50%" border="0" align="left" action="ReaddataTest.php" >
<tr>
<td width="11%"><b>Code</b></td>
<td width="16%"><input name="Code" type="text" id="Code" size ="10" />
<input type="BUTTON" name="btnPopup" value="Search" onclick="OpenPopup('TestSearchData.php', 'myPopup','width=750,height=700,toolbar=0, menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0')"></td>
<td width="11%"><b>Name</b></td>
<td width="23%"><input name="Name" type="text" id="Name" size ="30" style="background:#FFCC66" readonly />
</tr>

ตรงนี้คะ มันเป็น popup search คะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 16:53:55 By : guest
 


 

No. 27



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



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

นั่นแหละต้องดู code ไฟล์นี้อะ TestSearchData.php
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 17:04:44 By : kerb
 


 

No. 28

Guest


<?php
include "Connect1.php";
?>
<html>
<head>
<title>User</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<script language="javascript">
function selData(frmmain,Code,Name,Surname)
{
var sCode = self.opener.document.getElementById("Code" );
sCode.value = Code;

var sName = self.opener.document.getElementById("Name" );
sName.value = Name;

var sSurname = self.opener.document.getElementById("Surname" );
sSurname.value = Surname;

window.close();
}

</script>
<style type="text/css">
.ui-datepicker{
width:150px;
font-family:tahoma;
font-size:11px;
text-align:center;
}
TABLE {
border: 2px double green;
border-collapse: collapse;
}
TH {
text-align: left;
background:
padding: 1px;
border: 1px solid green;
}
TD {
padding: 1px;
border: 1px solid green;
}
</style>
<body>
<form name = 'SearchDataForm' action = '<?=$_SERVER['PHP_SELF']?>' method = 'post'>
<table align = 'center' border = '0' cellpadding = '3' cellspacing = '1' width = '50%'>
<tr>
<td colspan = '2' align = 'center'><font color="#000000" face='Browallia New' size='4'><b>ค้นหาข้อมูล</b></font></td>
</tr>
<tr>
<td align = 'right' width = '40%'><font color="#000000" face='Browallia New' size='4'>Code</font></td>
<td align = 'left' width = '60%'><input type = 'text' name = 'txtcode' id = 'txtcode' value = ''></td>
</tr>
<tr>
<td align = 'right' ><font color="#000000" face='Browallia New' size='4'>Name</font></td>
<td align = 'left' width = '60%'><input type = 'text' name = 'txtname' id = 'txtname' value = ''></td>
</tr>
<tr>
<td colspan = '2' align = 'center'>
<input type = 'submit' name = 'Search' value = 'ค้นหา' onclick = 'return validateRegis()';>
<input type = 'reset' name = 'reset' value = 'เริ่มต้นใหม่'>
</td>
</tr>
</table>
</form>
<?
if(isset($_POST['Search']))
{
//echo "<br />";
if(Trim($_POST["txtcode"]) != "" or Trim($_POST["txtname"]) != "")
{
$where = " WHERE ";
}
if(Trim($_POST["txtcode"]) != ""){
$where .= " User_Code LIKE '%".$_POST["txtcode"]."%', ";
}
if(Trim($_POST["txtname"]) != ""){
$where .= " User_Name LIKE '%".$_POST["txtname"]."%', ";
}
$where=eregi_replace(', $', '', $where);
$strSQL = "SELECT
tbl_user.ID,
tbl_user.User_Code,
tbl_user.User_Name,
tbl_user.Surname,
tbl_user.Group,
tbl_group.Group_Code,
tbl_group.Group_Name
FROM
tbl_user
INNER JOIN tbl_group ON tbl_user.Group = tbl_group.Group_Code
$where";
//echo "$strSQL";
//$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 200; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;

$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}

$strSQL .=" LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table width="90%" border="1">
<tr>
<th>Code</th>
<th>Name</th>
<th>Surname</th>
<th>Group</th>
</tr>
<?
$i=1;
if($Page > 1)
{
$i = ($Per_Page * ($Page-1)) + 1;
}
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr class="style1">
<td><font color="#000099" bgcolor="#FFFFCC" face='Browallia New' size='4'><div align="left"><a href="#" OnClick="selData('<?=$_GET["Line"];?>' ,'<?=$objResult["User_Code"];?>','<?=$objResult["User_Name"];?>' ,'<?=$objResult["Surname"];?>');">
<?=$objResult["User_Code"];?></a></div></font></td>
<td><font color="#000000" bgcolor="#FFFFCC" face='Browallia New' size='4'><?=$objResult["User_Name"];?></font></td>
<td><font color="#000000" bgcolor="#FFFFCC" face='Browallia New' size='4'><?=$objResult["Surname"];?></font></td>
<td><font color="#000000" bgcolor="#FFFFCC" face='Browallia New' size='4'><?=$objResult["Group_Code"];?></font></td>

</font></tr>
<?
$i++;
}
?>
</table> <br>
<div align="center">ค้นพบทั้งหมดจำนวน
<?= $Num_Rows;?>
รายการ :
<?=$Num_Pages;?>
หน้า :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}

for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
}
?>
</table>
</body>
</html>

อยู่นี่คะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-10 17:46:50 By : guest
 


 

No. 29



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



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

งง flow อะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-11 09:06:18 By : kerb
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : หนูเอาตัวอย่างจากกระทู้ในนี้ของพี่วิน มาลองทำดูคะ แล้วหนูใช้วิธีการ Search จาก Code แล้วให้ข้อมูลมัน show ตาม Text box แล้วอยากให้ group มัน Show เป็น list box โดย อิงจาก Code ที่เรา Search
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 02
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 อัตราราคา คลิกที่นี่