อัพ sql 2 ตัวในหน้าเดียวกันยังไงอ่ะครับ Code ประมาณนี้นะครับ หน้า index.php
Code ประมาณนี้นะครับ
หน้า index.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=windows-874" />
<title>Untitled Document</title>
<link href="css/css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form name="form1" method="post" action="vote.php">
<table width="95%" border="0" cellpadding="0" cellspacing="0" class="font">
<tr>
<td>
<table width="500" border="0" cellspacing="0" cellpadding="0" class="font">
<tr>
<td colspan="2">
<b><?
include("connect.inc");
$sql = "SELECT * FROM `poll_g` WHERE g_id = '1' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['g_main'];
?> </b> </td>
</tr>
<tr>
<td colspan="2"> <?
include("connect.inc");
$sql = "SELECT * FROM `poll_q` WHERE g_id = '1' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?></td>
</tr>
<?
$q_id = $row['q_id'];
$sql = "Select * from poll_a where q_id = '1' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row =mysql_fetch_array($query);
?>
<tr>
<td width="26"><input name="RadioGroup1" type="radio" value="<?=$row['a_id']?>" ></td>
<td width="474"><?=$row['a_answer']?></td>
<? }?>
</tr>
</table>
<br />
<table width="500" border="0" cellspacing="0" cellpadding="0" class="font">
<tr>
<td colspan="2">
<?
include("connect.inc");
$sql = "SELECT * FROM `poll_q` WHERE q_id = '2'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
</tr>
<?
$q_id = $row['q_id'];
$sql = "Select * from poll_a where q_id = '2' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row =mysql_fetch_array($query);
?>
<tr>
<td width="25"><input name="RadioGroup2" type="radio" value="<?=$row['a_id']?>"></td>
<td width="475"><?=$row['a_answer']?></td>
<? } ?>
</tr>
</table>
<br />
<table width="722" border="0" cellspacing="0" cellpadding="0" class="font">
<tr>
<td colspan="3"><b><?
include("connect.inc");
$sql = "SELECT * FROM `poll_g` WHERE g_id = '2' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['g_main'];
?></b></td>
</tr>
<tr>
<td width="606">
<?
include("connect.inc");
$sql = "SELECT * FROM `poll_q` WHERE q_id = '3'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
<?
$q_id = $row['q_id'];
$sql = "Select * from poll_a where q_id = '3' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row =mysql_fetch_array($query);
?>
<td width="20"><input name="RadioGroup3" type="radio" value="<?=$row['a_id']?>" /></td>
<td width="96"><?=$row['a_answer']?></td>
<? }?>
</tr>
<tr>
<td width="606" >
<?
include("connect.inc");
$sql = "SELECT * FROM `poll_q` WHERE q_id = '4'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
<?
$q_id = $row['q_id'];
$sql = "Select * from poll_a where q_id = '4' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row =mysql_fetch_array($query);
?>
<td width="20"><input name="RadioGroup4" type="radio" value="<?=$row['a_id']?>" /></td>
<td width="96"><?=$row['a_answer']?></td>
<? }?>
</tr>
<tr>
<td><?
include("connect.inc");
$sql = "SELECT * FROM `poll_q` WHERE q_id = '5'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
<?
$q_id = $row['q_id'];
$sql = "Select * from poll_a where q_id = '5' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row =mysql_fetch_array($query);
?>
<td width="20"><input name="RadioGroup5" type="radio" value="<?=$row['a_id']?>" /></td>
<td width="96"><?=$row['a_answer']?></td>
<? } ?>
</tr>
<tr>
<td><?
include("connect.inc");
$sql = "SELECT * FROM `poll_q` WHERE q_id = '6'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
<?
$q_id = $row['q_id'];
$sql = "Select * from poll_a where q_id = '6' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row =mysql_fetch_array($query);
?>
<td width="20"><input name="RadioGroup6" type="radio" value="<?=$row['a_id']?>" /></td>
<td width="96"><?=$row['a_answer']?></td>
<? } ?>
</tr>
<tr>
<td><?
include("connect.inc");
$sql = "SELECT * FROM `poll_q` WHERE q_id = '7'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
<?
$q_id = $row['q_id'];
$sql = "Select * from poll_a where q_id = '7' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row =mysql_fetch_array($query);
?>
<td width="20"><input name="RadioGroup7" type="radio" value="<?=$row['a_id']?>" /></td>
<td width="96"><?=$row['a_answer']?></td>
<? } ?>
</tr>
<tr>
<td><?
include("connect.inc");
$sql = "SELECT * FROM `poll_q` WHERE q_id = '8'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
<?
$q_id = $row['q_id'];
$sql = "Select * from poll_a where q_id = '8' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row =mysql_fetch_array($query);
?>
<td width="20"><input name="RadioGroup8" type="radio" value="<?=$row['a_id']?>" /></td>
<td width="96"><?=$row['a_answer']?></td>
<? } ?>
</tr>
<tr>
<td><?
include("connect.inc");
$sql = "SELECT * FROM `poll_q` WHERE q_id = '9'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
<?
$q_id = $row['q_id'];
$sql = "Select * from poll_a where q_id = '9' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row =mysql_fetch_array($query);
?>
<td width="20"><input name="RadioGroup9" type="radio" value="<?=$row['a_id']?>" /></td>
<td width="96"><?=$row['a_answer']?></td>
<? } ?>
</tr>
</table>
<br />
<table width="500" border="0" cellspacing="2" cellpadding="0" class="font">
<tr>
<td colspan="3"><b><?
include("connect.inc");
$sql = "SELECT * FROM `poll_g` WHERE g_id = '3' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['g_main'];
?></b></td>
</tr>
<tr>
<td colspan="3">
<?
include("connect.inc");
$sql = "SELECT * FROM `poll_q` WHERE g_id = '3' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
</tr>
<tr>
<td width="76">ชื่อ-สกุล</td>
<td width="9">:</td>
<td width="415"><input name="name" type="text" class="border_search" id="name" /></td>
</tr>
<tr>
<td>บริษัท</td>
<td width="9">:</td>
<td width="415"><input name="company" type="text" class="border_search" id="company" /></td>
</tr>
<tr>
<td valign="top">ที่อยู่</td>
<td width="9" valign="top">:</td>
<td width="415"><textarea name="address" cols="45" rows="5" class="border_search" id="address"></textarea></td>
</tr>
<tr>
<td>โทรศัพท์</td>
<td width="9">:</td>
<td width="415"><input name="tel" type="text" class="border_search" id="tel" /></td>
</tr>
<tr>
<td>โทรสาร</td>
<td width="9">:</td>
<td width="415"><input name="fax" type="text" class="border_search" id="fax" /></td>
</tr>
<tr>
<td>อีเมล์</td>
<td width="9">:</td>
<td width="415"><input name="email" type="text" class="border_search" id="email" /></td>
</tr>
<tr>
<td valign="top">ข้อเสนอแนะ</td>
<td width="9" valign="top">:</td>
<td width="415"><textarea name="comment" cols="45" rows="5" class="border_search" id="comment"></textarea></td>
</tr>
</table>
<br />
<table width="500" border="0" cellspacing="0" cellpadding="0" class="font">
<tr>
<td colspan="2"><?
include("connect.inc");
$sql = "SELECT * FROM `poll_q` WHERE q_id = '11'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
</tr>
<?
$q_id = $row['q_id'];
$sql = "Select * from poll_a where q_id = '11' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row =mysql_fetch_array($query);
?>
<tr>
<td width="25"><input name="RadioGroup11" type="radio" value="<?=$row['a_id']?>" /></td>
<td width="475"><?=$row['a_answer']?></td>
<? } ?>
</tr>
</table>?????????????????
<p align="center">
<input name="Submit" type="submit" class="border_search" value="ส่งข้อมูล" />
<input name="reset" type="reset" class="border_search" value="ยกเลิก" />
</p></td>
</tr>
</table>
</form>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------------------------------
Code หน้า Vote.php
-------------------------------------------------------------------------------------------------------------------------------------------
<?
include("connect.inc");
$sql2 = "insert into profile_vote values
('','$name','$company','$address','$tel','$fax','$email','$comment')";
mysql_query($sql2) or die ("insert error=$sql");
?>
<?
ob_start();
if(isset($_POST['RadioGroup1']))
{
$a_id = $_POST['RadioGroup1'];
$sql = "update poll_a set a_score=a_score+1 where a_id = '$a_id' ";
mysql_query($sql) or die ("Update error : $sql");
echo "<script>window.location='vote.php';</script>";
}
?>
<link href="css/css.css" rel="stylesheet" type="text/css" />
<table width="88%" border="0" cellpadding="0" cellspacing="0" class="font">
<tr>
<td>
<table width="500" border="0" cellspacing="0" cellpadding="0" class="font">
<tr>
<td colspan="2">
<b><?
$sql = "SELECT * FROM `poll_g` WHERE g_id = '1' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['g_main'];
?> </b> </td>
</tr>
<tr>
<td colspan="2"> <?
$sql = "SELECT * FROM `poll_q` WHERE g_id = '1' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?></td>
</tr>
<?
$q_id = $row['q_id'];
$sql = "select sum(a_score) as total from poll_a where q_id = '1' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
$total = $row['total'];
// echo $total;
$sql = "select * from poll_a where q_id = '1' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row = mysql_fetch_array($query);
$per = ($row['a_score']*100)/$total;
?>
<tr>
<td width="42" height="20"><font color="#0066FF"><?=number_format($per,2)?>%</font> </td>
<td width="458"><?=$row['a_answer']?><br /></td>
<? }?>
</tr>
</table>
<?
if(isset($_POST['RadioGroup2']))
{
$a_id = $_POST['RadioGroup2'];
$sql = "update poll_a set a_score=a_score+1 where a_id = '$a_id' ";
mysql_query($sql) or die ("Update error : $sql");
echo "<script>window.location='vote.php';</script>";//ตัด($_POST['a_id']) ออกไป
}
?>
<table width="500" border="0" cellspacing="0" cellpadding="0" class="font">
<tr>
<td colspan="2">
<?
include("connect.inc");
$sql = "SELECT * FROM `poll_q` WHERE q_id = '2'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
</tr>
<?
$q_id = $row['q_id'];
$sql = "select sum(a_score) as total from poll_a where q_id = '2' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
$total = $row['total'];
//echo $total;
$sql = "select * from poll_a where q_id = '2' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row = mysql_fetch_array($query);
$per = ($row['a_score']*100)/$total;
?>
<tr>
<td width="46"><font color="#0066FF"><?=number_format($per,2)?>%</font></td>
<td width="454"><?=$row['a_answer']?><br /></td>
<? } ?>
</tr>
</table>
<br />
<?
if(isset($_POST['RadioGroup3']))
{
$a_id = $_POST['RadioGroup3'];
$sql = "update poll_a set a_score=a_score+1 where a_id = '$a_id' ";
mysql_query($sql) or die ("Update error : $sql");
echo "<script>window.location='vote.php';</script>";//ตัด($_POST['a_id']) ออกไป
}
?>
<table width="942" border="0" cellspacing="0" cellpadding="0" class="font">
<tr>
<td colspan="3"><b>
<?
$sql = "SELECT * FROM `poll_g` WHERE g_id = '2' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['g_main'];
?></b></td>
</tr>
<tr>
<td width="659">
<?
$sql = "SELECT * FROM `poll_q` WHERE q_id = '3'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
<?
$q_id = $row['q_id'];
$sql = "select sum(a_score) as total from poll_a where q_id = '3' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
$total = $row['total'];
//echo $total;
$sql = "select * from poll_a where q_id = '3' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row = mysql_fetch_array($query);
$per = ($row['a_score']*100)/$total;
?>
<td width="89"><font color="#0066FF"><?=number_format($per,2)?>%</font> </td>
<td width="154"><?=$row['a_answer']?></td>
<? }?>
</tr>
<?
if(isset($_POST['RadioGroup4']))
{
$a_id = $_POST['RadioGroup4'];
$sql = "update poll_a set a_score=a_score+1 where a_id = '$a_id' ";
mysql_query($sql) or die ("Update error : $sql");
echo "<script>window.location='vote.php';</script>";//ตัด($_POST['a_id']) ออกไป
}
?>
<tr>
<td width="659" >
<?
$sql = "SELECT * FROM `poll_q` WHERE q_id = '4'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
<?
$q_id = $row['q_id'];
$sql = "select sum(a_score) as total from poll_a where q_id = '4' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
$total = $row['total'];
// echo $total;
$sql = "select * from poll_a where q_id = '4' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row = mysql_fetch_array($query);
$per = ($row['a_score']*100)/$total;
?>
<td width="89"><font color="#0066FF"><?=number_format($per,2)?>%</font> </td>
<td width="154"><?=$row['a_answer']?></td>
<? }?>
</tr>
<?
if(isset($_POST['RadioGroup5']))
{
$a_id = $_POST['RadioGroup5'];
$sql = "update poll_a set a_score=a_score+1 where a_id = '$a_id' ";
mysql_query($sql) or die ("Update error : $sql");
echo "<script>window.location='vote.php';</script>";//ตัด($_POST['a_id']) ออกไป
}
?>
<tr>
<td><?
include("connect.inc");
$sql = "SELECT * FROM `poll_q` WHERE q_id = '5'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
<?
$q_id = $row['q_id'];
$sql = "select sum(a_score) as total from poll_a where q_id = '5' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
$total = $row['total'];
//echo $total;
$sql = "select * from poll_a where q_id = '5' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row = mysql_fetch_array($query);
$per = ($row['a_score']*100)/$total;
?>
<td width="89"><font color="#0066FF"><?=number_format($per,2)?>%</font> </td>
<td width="154"><?=$row['a_answer']?></td>
<? } ?>
</tr>
<?
if(isset($_POST['RadioGroup6']))
{
$a_id = $_POST['RadioGroup6'];
$sql = "update poll_a set a_score=a_score+1 where a_id = '$a_id' ";
mysql_query($sql) or die ("Update error : $sql");
echo "<script>window.location='vote.php';</script>";//ตัด($_POST['a_id']) ออกไป
}
?>
<tr>
<td><?
$sql = "SELECT * FROM `poll_q` WHERE q_id = '6'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
<?
$q_id = $row['q_id'];
$sql = "select sum(a_score) as total from poll_a where q_id = '6' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
$total = $row['total'];
//echo $total;
$sql = "select * from poll_a where q_id = '6' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row = mysql_fetch_array($query);
$per = ($row['a_score']*100)/$total;
?>
<td width="89"><font color="#0066FF"><?=number_format($per,2)?>%</font> </td>
<td width="154"><?=$row['a_answer']?></td>
<? } ?>
</tr>
<?
if(isset($_POST['RadioGroup7']))
{
$a_id = $_POST['RadioGroup7'];
$sql = "update poll_a set a_score=a_score+1 where a_id = '$a_id' ";
mysql_query($sql) or die ("Update error : $sql");
echo "<script>window.location='vote.php';</script>";//ตัด($_POST['a_id']) ออกไป
}
?>
<tr>
<td><?
$sql = "SELECT * FROM `poll_q` WHERE q_id = '7'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
<?
$q_id = $row['q_id'];
$sql = "select sum(a_score) as total from poll_a where q_id = '7' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
$total = $row['total'];
//echo $total;
$sql = "select * from poll_a where q_id = '7' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row = mysql_fetch_array($query);
$per = ($row['a_score']*100)/$total;
?>
<td width="89"><font color="#0066FF"><?=number_format($per,2)?>%</font> </td>
<td width="154"><?=$row['a_answer']?></td>
<? } ?>
</tr>
<?
if(isset($_POST['RadioGroup8']))
{
$a_id = $_POST['RadioGroup8'];
$sql = "update poll_a set a_score=a_score+1 where a_id = '$a_id' ";
mysql_query($sql) or die ("Update error : $sql");
echo "<script>window.location='vote.php';</script>";//ตัด($_POST['a_id']) ออกไป
}
?>
<tr>
<td><?
$sql = "SELECT * FROM `poll_q` WHERE q_id = '8'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
<?
$q_id = $row['q_id'];
$sql = "select sum(a_score) as total from poll_a where q_id = '8' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
$total = $row['total'];
//echo $total;
$sql = "select * from poll_a where q_id = '8' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row = mysql_fetch_array($query);
$per = ($row['a_score']*100)/$total;
?>
<td width="89"><font color="#0066FF"><?=number_format($per,2)?>%</font> </td>
<td width="154"><?=$row['a_answer']?></td>
<? } ?>
</tr>
<?
if(isset($_POST['RadioGroup9']))
{
$a_id = $_POST['RadioGroup9'];
$sql = "update poll_a set a_score=a_score+1 where a_id = '$a_id' ";
mysql_query($sql) or die ("Update error : $sql");
echo "<script>window.location='vote.php';</script>";//ตัด($_POST['a_id']) ออกไป
}
?>
<tr>
<td><?
$sql = "SELECT * FROM `poll_q` WHERE q_id = '9'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
<?
$q_id = $row['q_id'];
$sql = "select sum(a_score) as total from poll_a where q_id = '9' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
$total = $row['total'];
//echo $total;
$sql = "select * from poll_a where q_id = '9' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row = mysql_fetch_array($query);
$per = ($row['a_score']*100)/$total;
?>
<td width="89"><font color="#0066FF"><?=number_format($per,2)?>%</font> </td>
<td width="154"><?=$row['a_answer']?></td>
<? } ?>
</tr>
</table>
<br />
<table width="500" border="0" cellspacing="0" cellpadding="0" class="font">
<tr>
<?
if(isset($_POST['RadioGroup11']))
{
$a_id = $_POST['RadioGroup11'];
$sql = "update poll_a set a_score=a_score+1 where a_id = '$a_id' ";
mysql_query($sql) or die ("Update error : $sql");
echo "<script>window.location='vote.php';</script>";//ตัด($_POST['a_id']) ออกไป
}
?>
<td colspan="2"><?
$sql = "SELECT * FROM `poll_q` WHERE q_id = '11'";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
echo $row['q_question'];
?> </td>
</tr>
<?
$q_id = $row['q_id'];
$sql = "select sum(a_score) as total from poll_a where q_id = '11' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$row = mysql_fetch_array($query);
$total = $row['total'];
$sql = "select * from poll_a where q_id = '11' ";
$query = mysql_query($sql) or die ("Select error : $sql");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row = mysql_fetch_array($query);
$per = ($row['a_score']*100)/$total;
?>
<tr>
<td width="25"><font color="#0066FF"><?=number_format($per,2)?>%</font> </td>
<td width="475"><?=$row['a_answer']?></td>
<? } ?>
</tr>
</table>?????????????????
<p>*** หมายเหตุ รวมจำนวน ผู้โหวต ทั้งหมด<font color="#0066FF"> <? echo $total; ?></font> คน</p>
</td>
</tr>
</table>
---------------------------------------------------------------------------------------------------------------------------------------------
ตอนอัพ พวกข้อมูล ของส่วน
$sql2 = "insert into profile_vote values
('','$name','$company','$address','$tel','$fax','$email','$comment')";
mysql_query($sql2) or die ("insert error=$sql");
มันอัพ แล้ว เพิ่ม ฟิลล์ ว่าง ลง DB อีกแถวนึงอ่ะครับ
อยากทีบว่าผิดอะไรอ่ะครับ
ขอขอบพระคุณล่วงหน้าครับTag : - - - -
Date :
2009-06-25 14:02:47
By :
Black-Hawk
View :
932
Reply :
2
ควรระบุชนืดน่ะครับ ว่าตัวแปรเป็นชนิดอะไรน่ะครับ
Code (PHP)
<?php
$sql2 = "insert into profile_vote values
('','$_POST[name]','$_POST[company]','$_POST[address]','$_POST[tel]','$_POST[fax]','$_POST[email]','$_POST[comment]')";
mysql_query($sql2) or die ("insert error=$sql");
?>
Date :
2009-06-25 15:03:29
By :
webmaster
ลองแล้วครับ เป็นเหมือนเดิม มันแถมแถวว่างให้อีกแถวนึงอ่ะครับ
Date :
2009-06-26 13:46:45
By :
Black-Hawk
Load balance : Server 04