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 > ช่วยแก้โค้ด PHP ให้หน่อยครับ จนปัญญาผมจิง ขอผู้รู้หน่อยครับ



 

ช่วยแก้โค้ด PHP ให้หน่อยครับ จนปัญญาผมจิง ขอผู้รู้หน่อยครับ

 



Topic : 033600

Guest




เลือกข้อมูลผ่าน check box และ radio button หลายข้อครับ แต่ผลลัพย์ออกมาแค่เพียงข้อเดียวครับ แก้ไขหลายครั้งยังไม่สามารถทำได้เลยครับยังไงขอผู้รู้ช่วยแก้ให้หน่อยครับ

// โค้ดอันนี้สำหรับเลือกข้อมูล รับค่า ครับ



Code (PHP)
<?php
	session_start();
	include("../function/connect.php");
	include("../function/functions.php");
		  	$sql = "select * from question_analyse qa,topic_analyse ta where (";
		  	$d=1;
			for($i=1;$i<=$_GET[cout];$i++){
				$nout="chout".$i;
				if($_GET[$nout]!="" and $d<=1){
					$sql.=" qa.idtopic ='".$_GET[$nout]."'";
					$d++;
				}elseif($_GET[$nout]!=""){
					$sql.=" or qa.idtopic ='".$_GET[$nout]."'";
				}
			}
			for($i=1;$i<=$_GET[cin];$i++){
				$nout="chin".$i;
				if($_GET[$nout]!="" and $d<=1){
					$sql.=" qa.idtopic ='".$_GET[$nout]."'";
					$d++;
				}elseif($_GET[$nout]!=""){
					$sql.=" or qa.idtopic ='".$_GET[$nout]."'";
				}
			}
			$sql.=") and qa.idtopic = ta.idtopic order by ta.statustopic,ta.idtopic,qa.idquestion asc";
			$num = select($sql,2,26);
$pagesize = 5;
$page = page_limit($num,$pagesize, $_SESSION['pageid']);
$pages = explode("/",$page);
$start = $pages[0];
$totalpage = $pages[1];
$pageid = $pages[2];
			$sqlques = $sql." limit $start,$pagesize";
			$showques = select($sqlques,1,34);
?>
<!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=windows-874" />
<title>ระบบอายุรกรรมออนไลน์ &gt;&gt; การวิเคราะห์โรค</title>
</head>
<link rel="stylesheet" type="text/css" href="../function/filecss.css" />
<script language="javascript">
	var xmlhttp=createXml();
	function createXml(){
		var xmlHttp;
			if(window.ActiveXObject){
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}else if(window.XMLHttpRequest){
				xmlHttp=new XMLHttpRequest();
		}
			return xmlHttp;
	}
	function inputChoice(numch,val,met){
		xmlhttp.open("get","ajax_ch.php?num="+numch+"&val="+val+"&met="+met);
		xmlhttp.onreadystatechange=handleServer;
		xmlhttp.send(null);
	}
	function handleServer(){
		if(xmlhttp.readyState==4){
			if(xmlhttp.status==200){
					mess=xmlhttp.responseText;
					if(mess!=""){
					alert(mess);
					}
			}
		}
	}
</script>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2"><?php include_once("header.php");?></td>
  </tr>
  <tr>
 
  </tr>
  <tr>
    <td width="23%" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><br />
        <?php include("menu.php");?></td></tr>
      <tr>
        <td><?php include("login.php");?></td>
      </tr>
    </table>
    <br /></td>
    <td width="77%" valign="top"><br />
      <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="18">&nbsp;</td>
          <td>&nbsp;</td>
          <td background="../images/cont_05.jpg">&nbsp;</td>
          <td><div align="right"></div></td>
          <td width="18">&nbsp;</td>
        </tr>
        <tr>
          <td width="18">&nbsp;</td>
          <td width="86">&nbsp;</td>
          <td width="100%" background="../image/menu_08.gif" bgcolor="#FFB423" class="head_b"> กรุณาตอบคำถามให้ครบ เพื่อความถูกต้องในการวิเคราะห์ (จำนวน <?=$num?> ข้อ)</td>
          <td width="43"><div align="right"></div></td>
          <td width="18">&nbsp;</td>
        </tr>
        <tr>
          <td width="18">&nbsp;</td>
          <td>&nbsp;</td>
          <td background="../images/cont_16.jpg">&nbsp;</td>
          <td><div align="right"></div></td>
          <td width="18">&nbsp;</td>
        </tr>
        <tr>
          <td background="../images/cont_19.jpg" width="18">&nbsp;</td>
          <td colspan="3">
          <br />
                <table width="90%" border="0" align="center" cellpadding="5" cellspacing="0">
                  <tr>
                    <td><div align="left" class="black14"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="head_b"><u>หมายเหตุ</u></span>&nbsp;หากข้อใดไม่มีคำตอบหรือไม่ตรงกับลักษณะใด ๆ ของบ้านท่านเลย ให้ข้ามข้อนั้นไปได้ โปรแกรมจะไม่นำมาทำการวิเคราะห์
                    </div></td>
                  </tr>
            </table>
                <br />
                <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
		  <?php
			 $ra = 1;
			  $noch=1;
			  if($_SESSION['i'] == NULL)
			  {
			  	$_SESSION['i'] = 1;
			  }
		  	while($ques = mysql_fetch_array($showques,MYSQL_ASSOC))
			{
		  ?>
            <tr>
              <td><fieldset>
              <legend class="bold_b"><img src="../image/ttopic.gif" width="14" /> &nbsp;<?=$_SESSION['i']."."?><?=$ques['question']?></legend>
              <br />
			  <?php
			  		if($ques['picques'] <> "")
					{
			  ?>
						<center><img src="<?=$ques['picques']?>" /></center>
			  <?php
					}
			  	$sqlchoice = "select * from choice_analyse where idquestion = '".$ques['idquestion']."'";
				$showchoice = select($sqlchoice,1,91)
			  ?>
              <table width="85%" border="0" align="center" cellpadding="5" cellspacing="0">
			  <?php
				while($choice = mysql_fetch_array($showchoice,MYSQL_ASSOC))
				{
			  ?>
                <tr>
                  <td valign="middle" class="black"><?php 
				  	if($ques['typechoice'] == 1)
					{
					?>
						<input name="<?="ra".$ra?>" type="radio" value="<?=$choice['idchoice']?>" onclick="inputChoice(<?=$ques['idquestion']?>,this.value,1)" />
					<?php 
				  	}
					else
					{
				  ?>
				  		<input name="ch<?=$noch?>" type="checkbox" value="<?=$choice['idchoice']?>" id="ch<?=$noch++?>" onclick="inputChoice(<?=$ques['idquestion']?>,this.value,2)" />
				  <?php
				  	}
				  	if($choice['picchoice'] == "")
					{				  
				  		echo $choice['choice'];
				  	}
					elseif($choice['picchoice'] <> "" and $choice['choice'] <> "")
					{
				  ?>
				 <img src="<?=$choice['picchoice']?>" width="100" height="100" align="absmiddle" />&nbsp;<?=$choice['choice']?>
				  <?php
					}
					elseif($choice['picchoice'] <> "" and $choice['choice'] == "")
					{
				  ?>
				  		<img src="<?=$choice['picchoice']?>" width="100" height="100" align="absmiddle" />
				  <?php
				  	}
				  ?>				  </td>
                </tr>
			  <?php
			  	}
			  ?>
              </table><br />
              </fieldset><br />
</td>
            </tr>
			<?php
			$ra++;
			$_SESSION['i']++;
			}
			?>
          </table>
              <table width="95%" border="0" align="center" cellpadding="3" cellspacing="0">
                <tr>
                  <td><div align="right">
                        <?php
						if($_SESSION['pageid'] < $totalpage)
						{
				echo "[<a href = \"question_analyse.php?$_SERVER[QUERY_STRING]&pageid=".++$_SESSION[pageid]."\" class = \"navi\">Next >></a>]&nbsp;";
						}
						else
						{
?>
                    <input name="banalyse" type="button" id="banalyse" style="font-family: Tahoma; font-size:10pt; border: 1px solid #FFB629; font-weight:200 ; background-image:url(../images/menubar_02.jpg)" value="วิเคราะห์โรค" onclick="window.open('result_analyse.php','lookup','width=750,height=600,toolbar=no,status=yes,scrollbars=yes');location.replace('index.php')"/>
					<?php } ?>
                  </div></td>
                </tr>
            </table>          <br />
          <div align="justify" class="black">
            <div align="center"></div>
          </div></td>
          <td background="../images/cont_21.jpg" width="18">&nbsp;</td>
        </tr>
        <tr>
          <td width="18">&nbsp;</td>
          <td colspan="3" background="../images/cont_23.jpg">&nbsp;</td>
          <td width="18">&nbsp;</td>
        </tr>
      </table>
      <br /></td>
  </tr>
  <tr>
    <td colspan="2"><?php include_once("bot.php");?></td>
  </tr>
</table>
</body>
</html>


ส่วนโค้ดที่สอง เป็นส่วนของการรับค่า แสดงผลลัพธ์ออกมาครับ


Code (PHP)
<?php
	session_start();
	include("../function/connect.php");
	include("../function/functions.php");
	session_unregister('pageid');
?>
<!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=windows-874" />
<title>ผลการวิเคราะห์โรค</title>
<style type="text/css">
<!--
.style1 {
	font-family: Tahoma;
	font-size: 18px;
	font-weight: bold;
}
.style2 {
	font-family: Tahoma;
	font-size: 13px;
}
.style3 {font-family: Tahoma; font-size: 13px; font-weight: bold; }
-->
</style>
</head>

<body>
<table width="95%" border="0" align="center" cellpadding="10" cellspacing="0">
  <tr>
    <td bgcolor="#DDDDDD"><div align="center" class="style1">ระบบอายุรกรรมออนไลน์</div></td>
  </tr>
  <tr>
    <td><span class="style2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;จากข้อมูลส่วนประกอบต่าง ๆ ที่ได้รับมา ร่างการของคุณมีทั้งสิ่งที่ดีในร่างกายและสิ่งที่จะก่อให้เกิดอันตรายซึ่งจำเป็นที่ต้องตรวจและดูแลรักษาร่างการให้แข็งแรงอยู่ทุกวัน</span><br />
      <br />
      
      <?php
	  $haha="";
	  count($_SESSION['choice']);
	for($i=0;$i < ($_SESSION[choice]);$i++){
		echo $_SESSION[choice][$i][0];
		$sqlques = "select * from question_analyse where idquestion = '".$_SESSION['choice'][$i][0]."'";
		$ques = select($sqlques,3,43);
		$sqlchoice = "select * from choice_analyse where idchoice = '".$_SESSION['choice'][$i][1]."'";
		$choice = select($sqlchoice,3,43);
	  ?>
      <table width="95%" border="0" align="center" cellpadding="5" cellspacing="0">
        <?php 
			if($ques['question']!=$haha){
		?>
        <tr bgcolor="#EFEFEF">
          <td width="27%" class="style3"><div align="right">คำถามในการวิเคราะห์ : </div></td>
          <td width="73%" class="style2"><?=$ques['question']?></td>
        </tr>
        <?php
				$haha=$ques['question'];
		 	}
		?>
        <tr>
          <td width="27%" valign="top" class="style3"><div align="right">สิ่งที่คุณเลือก : </div></td>
          <td width="73%" class="style2">
          <?php
		  	if($choice['picchoice'] <> "")
			{
		  ?>
       		<img src="<?=$choice['picchoice']?>" width="100" height="100" />
          <?php
			}
			if($choice['choice'] <> "")
			{
				echo "&nbsp;".$choice['choice'];
			}
		  ?>
          </td>
        </tr>
        <tr>
          <td valign="top" class="style3"><div align="right">ผลที่จะได้รับ : </div></td>
          <td class="style2">
          <?php
		  	if($choice['result'] == 1)
			{
				echo "ดี";
			}
			else
			{
				echo "ไม่ดี";
			}
			echo "&nbsp;".$choice['result_text'];
		  ?>
          </td>
        </tr>
        <tr>
          <td valign="top" class="style3"><div align="right">วิธีแก้ไข : </div></td>
          <td class="style2">
          <?php
		  	if($choice['edit_pic'] <> "")
			{
		  ?>
          		<img src="<?=$choice['edit_pic']?>" width="100" height="100" />
          <?php
			}
			if($choice['edit_text'] <> "")
			{
				echo "&nbsp;".$choice['edit_text'];
			}
		  ?>
          </td>
        </tr>
      </table>
      <?php
	  	}
	  ?>
    </td>
  </tr>
</table>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div align="center">
      <input name="bprint" type="button" id="bprint" value="พิมพ์ผลการวิเคราะห์" onclick="window.print();this.style.display = 'none';" />
    </div></td>
  </tr>
</table>
</body>
</html>




Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-10-28 15:33:11 By : แต้ม View : 890 Reply : 1
 

 

No. 1



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

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

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

PHP Radio Button






Date : 2009-10-29 06:55:55 By : webmaster
 

   

ค้นหาข้อมูล


   
 

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