เช็คค่าว่างในradio btn ที่ได้จากการ include file ได้หรือไม่คะ ภาษาPHPค่ะ

ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา เช็คค่าว่างในradio btn ที่ได้จากการ include file ได้หรือไม่คะ ภาษาPHPค่ะ

เช็คค่าว่างในradio btn ที่ได้จากการ include file ได้หรือไม่คะ ภาษาPHPค่ะ
เป็นส่วนของการทำแบบประเมินค่ะ
- หน้าฟอร์มจะเป็นไฟล์หลักที่includeไฟล์หัวข้อในการประเมิน
- ในแต่ละไฟล์หัวข้อจะมี radio btnที่ให้เลือกระดับคะแนนคุณภาพ
- แล้วจะมีไฟล์saveที่ใช้เก็บข้อมูลที่ได้จากการประเมินค่ะ
 
ไม่ทราบว่าจะทำการเช็คค่าว่างของradio btnที่ไม่ได้ทำการเลือกประเมินอย่างไรคะ 
 


Theprat 180.183.191.xxx 25-12-2014 07:01:09

คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
  • เปลี่ยน


    ( หรือ เข้าใช้งานผ่าน Social Login )

 ความคิดเห็นที่ 1


ninenik 124.122.90.xxx 25-12-2014
 ความคิดเห็นที่ 2
ส่วนที่เกี่ยวข้องจะมีทั้งหมด 3 ส่วนค่ะ

***1 หน้าฟอร์มการประเมินค่ะ

<?php
$UserCar=$_GET['UserCar'];


?>
<!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>ฟอร์มประเมินการให้บริการ</title>

<script type="text/javascript" src="../jQueryui_timepicker/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../jQueryui_timepicker/jquery-ui.min.js"></script>

<script type="text/javascript" src="../jQueryui_timepicker/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="../jQueryui_timepicker/jquery-ui-sliderAccess.js"></script>

</head>

<body background="../Image/graymap.png">

<br />
<form id="form1" name="form1" action="save_assess.php" method="post" onSubmit="JavaScript:return fncSubmit();">
<input name="UserCar" type="hidden" value="<?php echo $UserCar;?>" />
<table width="1100" border="0" align="center" bgcolor="#FFFFFF">
  <tr>
    <td>&nbsp;</td>
    <td><H2 align="center">
    แบบฟอร์มประเมินการให้บริการ</H2></td>
    <td>&nbsp;</td>
  </tr>
  
  <tr>
    <td>&nbsp;</td>
    <td align="center">คำชี้แจง : กรุณาทำแบบประเมินการให้บริการของรถโดยสารประจำทางองค์การขนส่งมวลชนกรุงเทพ</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
    
<table width="100%" border="0" align="center">
   <tr>
    <td colspan="6">ส่วนที่ 2 : ประเมินการให้บริการ</td>
    </tr>
    <tr align="center" bgcolor="#FFFF99"><b>
    <td>ความพึงพอใจการให้บริการ</td>
    <td width="116">มากที่สุด</td>
    <td width="116">มาก</td>
    <td width="116">ปานกลาง</td>
    <td width="116">น้อย</td>
    <td width="116">ควรปรับปรุง</td></b>
    
    </tr>
      <tr bgcolor="#99CCFF">
    <td colspan="6">ด้านการบริการ</td>
    </tr>
    <tr>
    <td colspan="6"><?php include('../qtype1.php'); ?></td>
    
  	
    </tr>
    <tr bgcolor="#99CCFF">
      <td colspan="6">ด้านบุคคล</td>
    </tr>
<tr>
  <td colspan="6"><?php include('../qtype2.php'); ?></td>
    
    
    </tr>
    <tr bgcolor="#99CCFF">
      <td colspan="6">ด้านสิ่งอำนวยความสะดวก</td>
    </tr>
    
<tr>
  <td colspan="6"><?php include('../qtype3.php'); ?></td>
     
      
    </tr>
<td>
  <input name="btnsave" type="submit" value="บันทึก"  />
  <input name="btnclear" type="reset" value="ยกเลิก" />
     
    
</td>
    </table>

</td>
    
  </tr>
  
  <tr>
  
</tr>

</table>
</form>
<br />
</body>
</html>


***2ตัวอย่างหน้าคำถาม (อันนี้เป็นหัวข้อคำถามประเภทที่1)

<?php require_once('Connections/FinalConn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
mysql_select_db($database_FinalConn, $FinalConn);
$query_qtype1 = "SELECT * FROM assess_question WHERE qtype=1";
$qtype1 = mysql_query($query_qtype1, $FinalConn) or die(mysql_error());
$row_qtype1 = mysql_fetch_assoc($qtype1);
$totalRows_qtype1 = mysql_num_rows($qtype1);
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
 
<body>
<table border="0" width="100%" align="center">
<?php for ($i=1;$i<=$row_qtype1;$i++) { ?>
 
 
 
 
  <?php do { ?>
    <tr>
      <td ><?php echo $i++; ?></td>
      <td><?php echo $row_qtype1['questions']; ?></td>  
      <td width="116" align="center"><input type="radio" name="<?php echo 'ch'.$row_qtype1['idq']; ?>" value="5" id="ch5q1">
      <label for="ch5q1"></label></td>
      <td width="116" align="center"><input type="radio" name="<?php echo 'ch'.$row_qtype1['idq']; ?>" value="4" id="ch4q1">
      <label for="ch4q1"></label></td>
      <td width="116" align="center"><input name="<?php echo 'ch'.$row_qtype1['idq']; ?>" type="radio" id="ch3q1" value="3">
      <label for="ch3q1"></label></td>
      <td width="116" align="center"><input type="radio" name="<?php echo 'ch'.$row_qtype1['idq']; ?>" value="2" id="ch2q1">
      <label for="ch2q1"></label></td>
      <td width="116" align="center"><input type="radio" name="<?php echo 'ch'.$row_qtype1['idq']; ?>" value="1" id="ch1q1">
      <label for="ch1q1"></label></td>
    
    </tr>
    <?php } while ($row_qtype1 = mysql_fetch_assoc($qtype1)); ?>
</table>
<?php } ?>
</body>
<?php
mysql_free_result($qtype1);
?>
***#หน้าsaveข้อมูล
<?php require_once('../Connections/FinalConn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
mysql_select_db($database_FinalConn, $FinalConn);
$query_Recordset1 = "SELECT * FROM assess_ch";
$Recordset1 = mysql_query($query_Recordset1, $FinalConn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
 
 
$ip = $_SERVER['REMOTE_ADDR']; 
$now = date("Y-m-d H:i:s");
 
$UserCar=$_POST["UserCar"];
$day=$_POST["dateInput"];
$times=$_POST["timeInput"];
$numbus=$_POST["numbus"];
$numplate=$_POST["numplate"];
$ndrive=$_POST["namedriver"];
$ntick=$_POST["nameticket"];
$question=array();
for($i=1;$i<=(count($_POST)-8);$i++){
$question[$i]=$_POST["ch".$i];
}
 
?>
<!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></title>
</head>
 
<body>
 
 
<?php
$sql="insert into assess_ch values('','$UserCar','$day','$times','$numbus','$numplate','$ndrive','$ntick','$ip','$now')";
$result=mysql_db_query($database_FinalConn,$sql);
if (!$result) {
 
echo "ขออภัยไม่สามารถบันทึกข้อมูลได้";
exit;
}else{
$ch=mysql_insert_id();
$sql="insert into assess_score values";
for($i=1;$i<=(count($question));$i++){
$arr_sql[] =" ('$ch','$i','{$question[$i]}')";
 
}
$sql .= implode(',' ,$arr_sql);
 
 
mysql_query($sql) or die(mysql_error().$sql);
 
 
echo "<H3>บันทึกข้อมูลเสร็จเรียบร้อย</H3>";
 
}
?>
<a href="../Admin/Assessment.php"><h5 align="center">...กลับหน้าประเมินการให้บริการ</h5>
</a>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
มันเป็นแบบนี้แหละค่ะ ไม่รู้จะเช็คradio  button ที่ยังไม่ได้เลือกยังไง  ลองเขียนตามโ๕๊ดที่ไกล์ๆกันมา ันก็ยังเซฟให้ปกติเลยค่ะ :(


Theprat 49.230.79.xxx 09-01-2015 05:30






เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ