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 > ใครทำ list menu ให้แสดงเฉพาะในส่วนที่เราเลือกบ้างได้ค่ะ ช่วยตอบให้หน่อยนะค่ะว่าทำยังไง



 

ใครทำ list menu ให้แสดงเฉพาะในส่วนที่เราเลือกบ้างได้ค่ะ ช่วยตอบให้หน่อยนะค่ะว่าทำยังไง

 



Topic : 113488



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



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




พอเราเลือกสาขาวิชาแล้วใ้ห้มันแสดงเฉพาะที่เราเลือก



Tag : PHP, MySQL, CakePHP, WebService







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-12-26 13:43:15 By : preedaporn View : 954 Reply : 12
 

 

No. 1



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



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


คือเมื่อเราเลือก สาขาวิชาแล้ว ให้มันแสดงเฉพาะอันที่เราเลือกนะค่ะ เช่น
เลือก information ให้แสดงบรรทัด information นะค่ะ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-12-26 13:45:26 By : preedaporn
 


 

No. 2



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



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


อันนี้ผมขอถามก่อนนะครับว่า ตรงตารางที่แสดงข้อมูล (List Of Item) นี่ ดึงข้อมูลมาจากการใช้คำสั่ง SQL หรือเปล่า ถ้าใช่ วิธีการก็คือ กำหนดค่า value ของ dropdown ไปนะครับ ว่าแต่ละ option จะมี value อะไรบ้าง เช่น <option value="info">Information</option> แล้วก็ส่งค่าดังกล่าวไปยังคำสั่ง SQL ที่ใช้ดึงข้อมูลนะครับ

ป.ล. ถ้าเป็นไปได้ อาจจะให้ จขกท รบกวนวาง script มาให้ดูก่อนนะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-12-26 14:02:45 By : Pangpondpuen
 

 

No. 3



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



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


Code
<?php session_start(); include("config.inc.php"); include("lang/$language"); ?> <html> <head> <!-- จาวา แถบสี --> <script language="javascript"> function mOvr(src,clrOver){ if (!src.contains(event.fromElement)){ src.style.cursor = 'hand'; src.bgColor = clrOver; } } function mOut(src,clrIn){ if (!src.contains(event.toElement)){ src.style.cursor = 'default'; src.bgColor = clrIn; } } </script> <title>หัวข้อรายการแบบทดสอบ</title> <meta http-equiv="Content-Type" content="text/html; charset=windows-874"> <style type="text/css"> <!-- body { margin: 0px 0px; padding: 0px 0px} a:link { color: #005CA2; text-decoration: none} a:visited { color: #005CA2; text-decoration: none} a:active { color: #0099FF; text-decoration: underline} a:hover { color: #0099FF; text-decoration: underline} --> </style> </head> <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <div align="center"><img src="images/bennnnm.jpg" width="1024" height="170"> <img src="images/top11.gif" width="1024" height="15"></div> <table width="92%" border="0" align="right" height="68"> <tr> <td width="21%">&nbsp;</td> <td width="19%">&nbsp;</td> <td width="28%">&nbsp;</td> <td width="2%"><font face="MS Sans Serif, Microsoft Sans Serif" size="2"><img src="image/icon_members.gif" width="20" height="21"></font></td> <td width="30%"><font face="MS Sans Serif, Microsoft Sans Serif" size="2"> <a href="member/index.php"> <?php echo $NewMember;?></a></font></td> </tr> <tr> <td width="21%">&nbsp;</td> <td width="19%">&nbsp;</td> <td width="28%">&nbsp;</td> <td width="2%"><img src="image/icon_servertime.png" width="16" height="16"></td> <td width="30%"><font face="MS Sans Serif, Microsoft Sans Serif" size="2"> &nbsp;<a href="login.php"><?php echo $Register;?></a></font></td> </tr> </table> <p>&nbsp;</p> <p>&nbsp;</p> <form name="form1" method="post" action=""> <label for="select"></label> <div align="center"> <table width="500" border="0" align="right" cellpadding="0" cellspacing="0"> <tr> <td><div align="center"> [color=black] <select name="select" id="select2"> <option value="index.php">&gt;&gt;เลือกสาขาวิชา&lt;&lt;</option> <option value="index.php">Information</option> <option>Thai</option> <option>Computer science</option> </select>[/color] </div></td> </tr> </table> </div> </form> <p>&nbsp;</p> <table border="0" cellpadding="3" cellspacing="1" bgcolor="#0066CC" height="16" width="75%" align="center"> <tr bgcolor="#0066FF"> <td height="30" colspan="6" bgcolor="#0066FF"> <p align="center"> <strong><font color="#FFFFFF" size="2" face="MS Sans Serif, Tahoma, sans-serif"><img src="image/light_blue.gif" width="12" height="12" align="absmiddle">&nbsp;&nbsp;<?php echo $ListOfItem; ?> &nbsp;<img src="image/light_blue.gif" width="12" height="12" align="absmiddle"></font></strong></p> </td> </tr> <tr bgcolor="#BBE2EA"> <td width="103" height="7" bgcolor="#BBE2EA"> <p align="center"><font size="2" face="MS Sans Serif, Microsoft Sans Serif"> &nbsp;&nbsp;<?php echo $Number; ?></font> </td> <td width="139" height="7"> <div align="center"><font size="2" face="MS Sans Serif, Microsoft Sans Serif"> <?php echo $ListOfItem; ?> </font></div> </td> <td width="200" height="7"> <div align="center"><font size="2" face="MS Sans Serif, Microsoft Sans Serif"> <?php echo $Discription; ?> </font></div> </td> <td width="68" height="7"> <div align="center"><font size="2" face="MS Sans Serif, Microsoft Sans Serif"> <?php echo $CreateDate; ?> </font></div> </td> </tr> <?php $sql="select * from group_question"; $result=mysql_db_query($db,$sql); $row=mysql_num_rows($result); $i=0; while ($choice = mysql_fetch_array($result)){ $i++; echo "<tr>"; echo "<td bgcolor=#FFFFFF width=69><div align=center><font size=2 face=MS Sans Serif, Tahoma, sans-serif>$i"; if ($choice[status]=="1"){ echo "<img src=../image/icon_dot.gif>"; } echo "</font></td>"; $group_select=$choice['tq_id']; echo "<td bgcolor=#FFFFF\ width=213><font size=2 face=MS Sans Serif, Tahoma, sans-serif><a href=showlink.php?select=",$choice['tq_id'],">",$choice['tq_name'],"</a></font></td>"; echo "<td bgcolor=#FFFFFF width=234><font size=2 face=MS Sans Serif, Tahoma, sans-serif>$choice[tq_discripton_th]</font></td>"; echo "<td bgcolor=#FFFFFF width=100><div align=center><font size=2 face=MS Sans Serif, Tahoma, sans-serif>$choice[date_create]</font></td>"; echo"</tr>"; } ?> </table> <br> <p>&nbsp;</p> <p>&nbsp;</p> </body> </html>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-12-26 14:07:09 By : preedaporn
 


 

No. 4



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



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


จะดึงข้อมูลมาจากฐานข้อมูล sql นะค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-12-26 14:10:12 By : preedaporn
 


 

No. 5



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



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


อ่าาาาา ถ้าดูจาก script ที่ให้มานั้น น่าจะเป็นการ submit post ในไฟล์เดิม (ไม่ได้กำหนด action นะครับ) ลองดูบรรทัดที่ 5, 71, 114 นะครับ (คือส่วนที่ผมแก้ไขและเพิ่มเติม)

Code (PHP)
<?php
session_start();
include("config.inc.php");
include("lang/$language");
/* หลังจากกด submit แล้วจะรับค่านี้มาจากตัว dropdown เพื่อนำไปใช้ในคำสั่ง SQL นะครับ */
$select = "";
if (isset($_POST['select']))
{
	$select = $_POST['select'];
}
?>
<html>
<head>

<!-- จาวา แถบสี -->
<script language="javascript">
function mOvr(src,clrOver){ 
if (!src.contains(event.fromElement)){ 
src.style.cursor = 'hand'; 
src.bgColor = clrOver; 
} 
} 
function mOut(src,clrIn){ 
if (!src.contains(event.toElement)){ 
src.style.cursor = 'default'; 
src.bgColor = clrIn; 
} 
}
</script> 

<title>หัวข้อรายการแบบทดสอบ</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<style type="text/css">
<!--
body { margin: 0px 0px; padding: 0px 0px}
a:link { color: #005CA2; text-decoration: none}
a:visited { color: #005CA2; text-decoration: none}
a:active { color: #0099FF; text-decoration: underline}
a:hover { color: #0099FF; text-decoration: underline}
-->
</style>
</head>

<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="center"><img src="images/bennnnm.jpg" width="1024" height="170">
<img src="images/top11.gif" width="1024" height="15"></div>
<table width="92%" border="0" align="right" height="68">
<tr>
<td width="21%">&nbsp;</td>
<td width="19%">&nbsp;</td>
<td width="28%">&nbsp;</td>
<td width="2%"><font face="MS Sans Serif, Microsoft Sans Serif" size="2"><img src="image/icon_members.gif" width="20" height="21"></font></td>
<td width="30%"><font face="MS Sans Serif, Microsoft Sans Serif" size="2"> <a href="member/index.php"> <?php echo $NewMember;?></a></font></td>
</tr>
<tr>
<td width="21%">&nbsp;</td>
<td width="19%">&nbsp;</td>
<td width="28%">&nbsp;</td>
<td width="2%"><img src="image/icon_servertime.png" width="16" height="16"></td>
<td width="30%"><font face="MS Sans Serif, Microsoft Sans Serif" size="2"> &nbsp;<a href="login.php"><?php echo $Register;?></a></font></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form name="form1" method="post" action="">
<label for="select"></label>
<div align="center">
<table width="500" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<!-- ผมไม่แน่ใจว่าใน db ของคุณเก็บค่าตัว dropdown นี้อย่างไรใน table ที่ชื่อว่า group_question นะครับ แต่ด้านล่าง ผมลองกำหนด value ให้ดูเป็นตัวอย่าง -->
 <select name="select" id="select2">
<option value="">&gt;&gt;เลือกสาขาวิชา&lt;&lt;</option>
<option value="info">Information</option>
<option value="thai">Thai</option>
<option value="comsci">Computer science</option>
</select>
</div></td>
</tr>
</table>
</div>
</form>
<p>&nbsp;</p>
<table border="0" cellpadding="3" cellspacing="1" bgcolor="#0066CC" height="16" width="75%" align="center">
<tr bgcolor="#0066FF"> 
<td height="30" colspan="6" bgcolor="#0066FF"> 
<p align="center"> <strong><font color="#FFFFFF" size="2" face="MS Sans Serif, Tahoma, sans-serif"><img src="image/light_blue.gif" width="12" height="12" align="absmiddle">&nbsp;&nbsp;<?php echo $ListOfItem; ?>
&nbsp;<img src="image/light_blue.gif" width="12" height="12" align="absmiddle"></font></strong></p>
</td>
</tr>
<tr bgcolor="#BBE2EA"> 
<td width="103" height="7" bgcolor="#BBE2EA"> 
<p align="center"><font size="2" face="MS Sans Serif, Microsoft Sans Serif"> 
&nbsp;&nbsp;<?php echo $Number; ?></font> 
</td>
<td width="139" height="7"> 
<div align="center"><font size="2" face="MS Sans Serif, Microsoft Sans Serif">
<?php echo $ListOfItem; ?>
</font></div>
</td>
<td width="200" height="7"> 
<div align="center"><font size="2" face="MS Sans Serif, Microsoft Sans Serif">
<?php echo $Discription; ?>
</font></div>
</td>
<td width="68" height="7"> 
<div align="center"><font size="2" face="MS Sans Serif, Microsoft Sans Serif">
<?php echo $CreateDate; ?>
</font></div>
</td>

</tr>
<?php
/* 
	นำค่า $select ที่ได้จากการ submit มาใช้ในเงื่อนไข where สำหรับการ select ข้อมูล
	fieldname คือชื่อฟิลด์ที่เก็บข้อมูลจากตัว dropdown นะครับ
*/
$sql="select * from group_question where fieldname='" . $select . "'";
$result=mysql_db_query($db,$sql);
$row=mysql_num_rows($result);
$i=0;
while ($choice = mysql_fetch_array($result)){ 
$i++;
echo "<tr>";
echo "<td bgcolor=#FFFFFF width=69><div align=center><font size=2 face=MS Sans Serif, Tahoma, sans-serif>$i";
if ($choice[status]=="1"){ 
echo "<img src=../image/icon_dot.gif>";
}
echo "</font></td>";
$group_select=$choice['tq_id'];
echo "<td bgcolor=#FFFFF\ width=213><font size=2 face=MS Sans Serif, Tahoma, sans-serif><a href=showlink.php?select=",$choice['tq_id'],">",$choice['tq_name'],"</a></font></td>";
echo "<td bgcolor=#FFFFFF width=234><font size=2 face=MS Sans Serif, Tahoma, sans-serif>$choice[tq_discripton_th]</font></td>";
echo "<td bgcolor=#FFFFFF width=100><div align=center><font size=2 face=MS Sans Serif, Tahoma, sans-serif>$choice[date_create]</font></td>";
echo"</tr>";
}
?>
</table>
<br>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>



ประวัติการแก้ไข
2014-12-26 14:21:27
2014-12-26 14:22:12
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-12-26 14:20:51 By : Pangpondpuen
 


 

No. 6



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



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


มันไม่ได้นะค่ะ
ไม่ได้


ฐานข้อมูลที่จะเรียกใช้นะค่ะ

ฐานข้อมูล
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-12-26 14:53:52 By : preedaporn
 


 

No. 7



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



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


ข้อมูล
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-12-26 15:04:34 By : preedaporn
 


 

No. 8



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



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


โทษทีนะครับ พอดีผมแก้โค้ด แต่ยังไม่ได้ run script สำหรับการทดสอบ ลองดูอันใหม่นะครับ สาเหตุที่ error เพราะครั้งแรกที่เปิดมา จะยังไม่มีค่า POST เข้ามา ทำให้ SQL ไม่พบข้อมูลที่เลือก ถ้ายังไม่ได้อีก ก็ PM มาหาผมได้เลยนะครับ

Code (PHP)
<?php
session_start();
include("config.inc.php");
include("lang/$language");
/* หลังจากกด submit แล้วจะรับค่านี้มาจากตัว dropdown เพื่อนำไปใช้ในคำสั่ง SQL นะครับ */
$select = "";
if (isset($_POST['select']))
{
	$select = " where fieldname LIKE '" . $_POST['select'] . "%'";
}
?>
<html>
<head>

<!-- จาวา แถบสี -->
<script language="javascript">
function mOvr(src,clrOver){ 
if (!src.contains(event.fromElement)){ 
src.style.cursor = 'hand'; 
src.bgColor = clrOver; 
} 
} 
function mOut(src,clrIn){ 
if (!src.contains(event.toElement)){ 
src.style.cursor = 'default'; 
src.bgColor = clrIn; 
} 
}
</script> 

<title>หัวข้อรายการแบบทดสอบ</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<style type="text/css">
<!--
body { margin: 0px 0px; padding: 0px 0px}
a:link { color: #005CA2; text-decoration: none}
a:visited { color: #005CA2; text-decoration: none}
a:active { color: #0099FF; text-decoration: underline}
a:hover { color: #0099FF; text-decoration: underline}
-->
</style>
</head>

<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="center"><img src="images/bennnnm.jpg" width="1024" height="170">
<img src="images/top11.gif" width="1024" height="15"></div>
<table width="92%" border="0" align="right" height="68">
<tr>
<td width="21%">&nbsp;</td>
<td width="19%">&nbsp;</td>
<td width="28%">&nbsp;</td>
<td width="2%"><font face="MS Sans Serif, Microsoft Sans Serif" size="2"><img src="image/icon_members.gif" width="20" height="21"></font></td>
<td width="30%"><font face="MS Sans Serif, Microsoft Sans Serif" size="2"> <a href="member/index.php"> <?php echo $NewMember;?></a></font></td>
</tr>
<tr>
<td width="21%">&nbsp;</td>
<td width="19%">&nbsp;</td>
<td width="28%">&nbsp;</td>
<td width="2%"><img src="image/icon_servertime.png" width="16" height="16"></td>
<td width="30%"><font face="MS Sans Serif, Microsoft Sans Serif" size="2"> &nbsp;<a href="login.php"><?php echo $Register;?></a></font></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form name="form1" method="post" action="">
<label for="select"></label>
<div align="center">
<table width="500" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<!-- ผมไม่แน่ใจว่าใน db ของคุณเก็บค่าตัว dropdown นี้อย่างไรใน table ที่ชื่อว่า group_question นะครับ แต่ด้านล่าง ผมลองกำหนด value ให้ดูเป็นตัวอย่าง -->
 <select name="select" id="select2">
<option value="">&gt;&gt;เลือกสาขาวิชา&lt;&lt;</option>
<option value="COM_01">Information</option>
<option value="THAI_01">Thai</option>
<option value="SOC_01">Computer science</option>
</select>
</div></td>
</tr>
</table>
</div>
</form>
<p>&nbsp;</p>
<table border="0" cellpadding="3" cellspacing="1" bgcolor="#0066CC" height="16" width="75%" align="center">
<tr bgcolor="#0066FF"> 
<td height="30" colspan="6" bgcolor="#0066FF"> 
<p align="center"> <strong><font color="#FFFFFF" size="2" face="MS Sans Serif, Tahoma, sans-serif"><img src="image/light_blue.gif" width="12" height="12" align="absmiddle">&nbsp;&nbsp;<?php echo $ListOfItem; ?>
&nbsp;<img src="image/light_blue.gif" width="12" height="12" align="absmiddle"></font></strong></p>
</td>
</tr>
<tr bgcolor="#BBE2EA"> 
<td width="103" height="7" bgcolor="#BBE2EA"> 
<p align="center"><font size="2" face="MS Sans Serif, Microsoft Sans Serif"> 
&nbsp;&nbsp;<?php echo $Number; ?></font> 
</td>
<td width="139" height="7"> 
<div align="center"><font size="2" face="MS Sans Serif, Microsoft Sans Serif">
<?php echo $ListOfItem; ?>
</font></div>
</td>
<td width="200" height="7"> 
<div align="center"><font size="2" face="MS Sans Serif, Microsoft Sans Serif">
<?php echo $Discription; ?>
</font></div>
</td>
<td width="68" height="7"> 
<div align="center"><font size="2" face="MS Sans Serif, Microsoft Sans Serif">
<?php echo $CreateDate; ?>
</font></div>
</td>

</tr>
<?php
/* 
	นำค่า $select ที่ได้จากการ submit มาใช้ในเงื่อนไข where สำหรับการ select ข้อมูล
	fieldname คือชื่อฟิลด์ที่เก็บข้อมูลจากตัว dropdown นะครับ
*/
$sql="select * from group_question " . $select;
$result=mysql_db_query($db,$sql);
$row=mysql_num_rows($result);
$i=0;
while ($choice = mysql_fetch_array($result)){ 
$i++;
echo "<tr>";
echo "<td bgcolor=#FFFFFF width=69><div align=center><font size=2 face=MS Sans Serif, Tahoma, sans-serif>$i";
if ($choice[status]=="1"){ 
echo "<img src=../image/icon_dot.gif>";
}
echo "</font></td>";
$group_select=$choice['tq_id'];
echo "<td bgcolor=#FFFFF\ width=213><font size=2 face=MS Sans Serif, Tahoma, sans-serif><a href=showlink.php?select=",$choice['tq_id'],">",$choice['tq_name'],"</a></font></td>";
echo "<td bgcolor=#FFFFFF width=234><font size=2 face=MS Sans Serif, Tahoma, sans-serif>$choice[tq_discripton_th]</font></td>";
echo "<td bgcolor=#FFFFFF width=100><div align=center><font size=2 face=MS Sans Serif, Tahoma, sans-serif>$choice[date_create]</font></td>";
echo"</tr>";
}
?>
</table>
<br>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-12-26 15:56:22 By : Pangpondpuen
 


 

No. 9



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



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


ขอบคุณนะค่ะ ที่แก้ให้ไม่ Error แล้วนะค่ะ

แต่ส่วนนี้ พอเราเลือก information มันไม่แสดงแค่ส่วนที่เลือกอย่างเดียวนะค่ะ

ไม่แสดง


ประวัติการแก้ไข
2014-12-26 17:47:51
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-12-26 17:47:04 By : preedaporn
 


 

No. 10



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



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


Code (PHP)
<?php
    //session_start();
    //include("config.inc.php");
    //include("lang/$language");

    $objConnect = mysql_connect("localhost","root","root") or die (mysql_error());
    $objDB = mysql_select_db("db_test") or die("Error Connect to Database");
    mysql_query("SET NAMES UTF8");
?>
<html>
    <head>
        <title>หัวข้อรายการแบบทดสอบ</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    </head>
    <body>
        <form name="frm1" method="post" action="<?PHP echo $_SERVER['PHP_SELF']?>">
            <select name="Select" onChange="this.form.submit()">
                <option value="">เลือกสาขาวิชา</option>
                <?php // ที่เขียนแบบนี้เพราะไม่รู้ว่าข้อมูลที่เอามาให้เลือกมันเพิ่มหรือปรับปรุ่งได้อีกหรือป่าว
                    $strSQL1 = "SELECT * FROM group_question GROUP BY tq_id"; // แสดงข้อมูลขึ้นมาให้เลือกแบบไม่ซ้ำกันโดยยึดจาก tq_id เป็นหลัก
                    $objQuery1 = mysql_query($strSQL1);
                    while($objResult1 = mysql_fetch_array($objQuery1)){

                    if($_POST['Select'] == $objResult1['tq_id']){ $selected = "selected"; }else{ $selected = ""; } // ให้ค่าที่เลือกยังแสดงอยู่ใน selectbox
                ?>
                <option value="<?=$objResult1['tq_id']?>" <?=$selected;?>><?=$objResult1['tq_name']?></option> <!-- ส่งค่าใน value ไป where ในจารางด้านล่าง -->
                <?php } ?>
            </select>
        </form>

        <table width="80%" border="1" cellpadding="1" cellspacing="0">
            <tr>
                <th colspan="4">List Of Item</th>
            </tr>
            <tr>
                <th width="20%">Number</th>
                <th width="20%">List Of Item</th>
                <th width="20%">Discription</th>
                <th width="20%">Date Create</th>
            </tr>
            <?php
                $i = 0;
                $strSQL2 = "SELECT * FROM group_question";
                if($_POST['Select'] != ""){ // ถ้า selectbox ไม่ใช่ค่าว่างให้ไป where ต่อ
                    $strSQL2 .= " WHERE tq_id = '".$_POST['Select']."'";
                }
                $objQuery2 = mysql_query($strSQL2);
                while($objResult2 = mysql_fetch_array($objQuery2)){
                $i++;
            ?>
            <tr>
                <td align=center><?=$i;?></td>
                <td><?=$objResult2['tq_name'];?></td>
                <td><?=$objResult2['tq_discripton_th'];?></td>
                <td><?=$objResult2['date_create'];?></td>
            </tr>
            <?php } ?>
        </table>
    </body>
</html>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-12-27 04:34:07 By : sabaitip
 


 

No. 11



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



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


มันขี้นแบบนี้นะค่ะ ใครก็ได้ช่วยแก้ให้ทีนะค่ะ
ok
Code (PHP)
<?php
	session_start();
	include("config.inc.php");
	include("lang/$language");
	$select = "";
	if (isset($_POST['select']))
	{
		$select = " where fieldname LIKE '" . $_POST['select'] . "%'";
	}
		?>
<html>
<head>

<!-- จาวา แถบสี -->
<script language="javascript">
function mOvr(src,clrOver){ 
if (!src.contains(event.fromElement)){ 
src.style.cursor = 'hand'; 
src.bgColor = clrOver; 
} 
} 
function mOut(src,clrIn){ 
if (!src.contains(event.toElement)){ 
src.style.cursor = 'default'; 
src.bgColor = clrIn; 
} 
}
</script> 

<title>หัวข้อรายการแบบทดสอบ</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<style type="text/css">
<!--
body {  margin: 0px  0px; padding: 0px  0px}
a:link { color: #005CA2; text-decoration: none}
a:visited { color: #005CA2; text-decoration: none}
a:active { color: #0099FF; text-decoration: underline}
a:hover { color: #0099FF; text-decoration: underline}
-->
</style>
</head>

<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="center"><img src="images/bennnnm.jpg" width="1024" height="170">
<img src="images/top11.gif" width="1024" height="15"></div>
<table width="92%" border="0" align="right" height="68">
  <tr>
    <td width="21%">&nbsp;</td>
    <td width="19%">&nbsp;</td>
    <td width="28%">&nbsp;</td>
    <td width="2%"><font face="MS Sans Serif, Microsoft Sans Serif" size="2"><img src="image/icon_members.gif" width="20" height="21"></font></td>
    <td width="30%"><font face="MS Sans Serif, Microsoft Sans Serif" size="2"> <a href="member/index.php"> <?php echo $NewMember;?></a></font></td>
  </tr>
  <tr>
    <td width="21%">&nbsp;</td>
    <td width="19%">&nbsp;</td>
    <td width="28%">&nbsp;</td>
    <td width="2%"><img src="image/icon_servertime.png" width="16" height="16"></td>
    <td width="30%"><font face="MS Sans Serif, Microsoft Sans Serif" size="2"> &nbsp;<a href="login.php"><?php echo $Register;?></a></font></td>
  </tr>
  </table>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <form name="form1" method="post" action="<?php echo $_SERVER['php_self']?>">
  <label for="select"></label>
  <div align="center">
  <table width="530" border="0" align="right" cellpadding="0" cellspacing="0">
  <tr>
   <td><div align="center">
      <select name="select"  onChange="this.form.submit()">
        <option value="">&gt;&gt;เลือกสาขาวิชา&lt;&lt;</option>
        <option value="COM_01">Information</option>
        <option value="THAI_01">Thai</option>
        <option value="SOC_01">Computer science</option>
        <?php
		$strsql1 = "SELECT * FROM group_question GROUP BY tq_id";
		$objQuery1 = mysql_query($strSQL1);
		while($objResult1 = mysql_fetch_array($objQuery1)){
			if($_POST['select'] == $objQuery1['tq_id']){ $selected = "selected";}else{ $selected = "";}
		?>
        <option value="<?=$objResult1['tq_id']?>"  <?=$selected;?>><?=$objResult1['tq_name']?></option>
        <?php } ?>
        </select>
       </div></td>
  <tr>
  </table>
  </div>
  </form>
<p>&nbsp;</p>
<table border="0" cellpadding="3" cellspacing="1" bgcolor="#0066CC" height="16" width="75%" align="center">
  <tr bgcolor="#0066FF"> 
    <td height="30" colspan="6" bgcolor="#0066FF"> 
      <p align="center"> <strong><font color="#FFFFFF" size="2" face="MS Sans Serif, Tahoma, sans-serif"><img src="image/light_blue.gif" width="12" height="12" align="absmiddle">&nbsp;&nbsp;<?php echo $ListOfItem; ?>
        &nbsp;<img src="image/light_blue.gif" width="12" height="12" align="absmiddle"></font></strong></p>
    </td>
  </tr>
  <tr bgcolor="#BBE2EA"> 
    <td width="103" height="7" bgcolor="#BBE2EA"> 
      <p align="center"><font size="2" face="MS Sans Serif, Microsoft Sans Serif"> 
        &nbsp;&nbsp;<?php echo $Number; ?></font> 
    </td>
    <td width="139" height="7"> 
      <div align="center"><font size="2" face="MS Sans Serif, Microsoft Sans Serif">
        <?php echo $ListOfItem; ?>
        </font></div>
    </td>
    <td width="200" height="7"> 
      <div align="center"><font size="2" face="MS Sans Serif, Microsoft Sans Serif">
        <?php echo $Discription; ?>
        </font></div>
    </td>
    <td width="68" height="7"> 
      <div align="center"><font size="2" face="MS Sans Serif, Microsoft Sans Serif">
        <?php echo $CreateDate; ?>
        </font></div>
    </td>
  </tr>
  <?php
  $i= 0;
  $strsql2="select * from group_question";
  if($_POST['select'] != "") {
	  $strSQL2 .= "WHERE tq_id = '".$_POST['select']."'";
  }
  $objQuery2 = mysql_query($strSQL2);
  while ($objResult2 = mysql_fetch_array($objQuery2)){ 
	$i++;
	?>
    <tr>
    <td align=center><?=$i;?></td>
    <td><?=$objResult2['tq_name'];?></td>
    <td><?=$objResult2['tq_discripton_th'];?></td>
    <td><?=$objResult2['date_create'];?></td>
    </tr>
	<?php
	  echo "<tr>";
      echo "<td bgcolor=#FFFFFF width=69><div align=center><font size=2 face=MS Sans Serif, Tahoma, sans-serif>$i";
	  	  if ($choice[status]=="1"){ 
	  	echo "<img src=../image/icon_dot.gif>";
	  }
	  echo "</font></td>";
	  $group_select=$choice['tq_id'];
      echo "<td bgcolor=#FFFFF\ width=213><font size=2 face=MS Sans Serif, Tahoma, sans-serif><a href=showlink.php?select=",$choice['tq_id'],">",$choice['tq_name'],"</a></font></td>";
      echo "<td bgcolor=#FFFFFF width=234><font size=2 face=MS Sans Serif, Tahoma, sans-serif>$choice[tq_discripton_th]</font></td>";
   	  echo "<td bgcolor=#FFFFFF width=100><div align=center><font size=2 face=MS Sans Serif, Tahoma, sans-serif>$choice[date_create]</font></td>";
      echo"</tr>";
	}
	?>
</table>
<br>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-12-27 13:52:19 By : preedaporn
 


 

No. 12



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



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


บรรทัด 76, 120 SQL ใหญ่

หน้า WHERE ผมใส่วรรคไว้ไปเอาออกทำไมหละครัชแหม่ ไม่งั้นก็เท่ากับเขียนติดกันหมดสิ


ประวัติการแก้ไข
2014-12-27 16:18:26
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-12-27 16:12:10 By : sabaitip
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ใครทำ 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 04
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 อัตราราคา คลิกที่นี่