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,038

HOME > PHP > PHP Forum > อัพ sql 2 ตัวในหน้าเดียวกันยังไงอ่ะครับ Code ประมาณนี้นะครับ หน้า index.php



 

อัพ sql 2 ตัวในหน้าเดียวกันยังไงอ่ะครับ Code ประมาณนี้นะครับ หน้า index.php

 



Topic : 028618

Guest




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>&nbsp;&nbsp;</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>&nbsp;&nbsp;</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>&nbsp;&nbsp;</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>&nbsp;&nbsp;</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>&nbsp;&nbsp;</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>&nbsp;&nbsp;</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>&nbsp;&nbsp;</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>&nbsp;&nbsp;</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>&nbsp;&nbsp;</td>
<td width="475"><?=$row['a_answer']?></td>
<? } ?>
</tr>
</table>?????????????????
<p>*** หมายเหตุ รวมจำนวน ผู้โหวต ทั้งหมด<font color="#0066FF">&nbsp;<? 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 : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-06-25 14:02:47 By : Black-Hawk View : 932 Reply : 2
 

 

No. 1



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

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

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

ควรระบุชนืดน่ะครับ ว่าตัวแปรเป็นชนิดอะไรน่ะครับ

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
 


 

No. 2

Guest


ลองแล้วครับ เป็นเหมือนเดิม มันแถมแถวว่างให้อีกแถวนึงอ่ะครับ
Date : 2009-06-26 13:46:45 By : Black-Hawk
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : อัพ sql 2 ตัวในหน้าเดียวกันยังไงอ่ะครับ Code ประมาณนี้นะครับ หน้า index.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 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่