설문조사용


<--survey.sql-->

 

create table eventuser(
no int unsigned NOT NULL auto_increment primary key,
name varchar(20),
S1 varchar(6),
) ENGINE=MyISAM CHARSET=euckr;


<--dbconn.inc.php-->

<?
$host_name='localhost';
$db_id='root';
$db_name='test';
$db_pass='1234';
$connect = mysql_connect($host_name,$db_id,$db_pass) or die(mysql_error('접속이 안되네요'));
mysql_select_db($db_name,$connect) or die(mysql_error());
mysql_query("set names euckr",$connect);
?>


<--insert.php-->

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />
<HTML>
<head>
  <TITLE> New Document </TITLE>
 </HEAD>

<form method="post" name="theForm" action="save.php">
이름 : <input type="text" name="name"><br><br>
1. 다음중에서 하나를 고르시오<br>
<input type="radio" name="S1" value="1"> (1)맞다
<input type="radio" name="S1" value="2"> (2)아니다
<input type="radio" name="S1" value="3"> (3)모른다
<input type="radio" name="S1" value="4"> (4)답변불응
<Br><Br>
<Input type="submit" value="저장">
</form>

 <BODY>
 
 </BODY>
</HTML>


<--save.php-->

 

<?
include "dbconn.inc.php";

$name  = $_POST['name'];
$S1 = $_POST['S1'];

echo iconv("etf-8","euc-kr",$_POST['name']);
echo iconv("etf-8","euc-kr",$_POST['S1']);

mysql_query("INSERT IGNORE INTO eventuser (name, S1) values('". $name ."', '". $S1 ."')");
?>

<Script Type='Text/Javascript' Language='Javascript'>
<!--

alert("저장 되었습니다.");
  document.location = "print.php";

//-->
</Script>


<--print.php-->

 

<?

include "dbconn.inc.php";

$sql = "select * from eventuser";
$result = mysql_query($sql, $connect);

$fields = mysql_num_fields($result);
echo "<table border=1>
 <tr>
  <td align='center'>순번</td>
  <td align='center'>이름</td>
  <td align='center'>1번</td>
 </tr>";
 while($row = mysql_fetch_row($result)){
echo"<tr>";
for($i=0; $i<=$fields; $i++){
 echo"<td align='center'>".$row[$i]."</td>";
}
echo "</tr>";
};
echo "</table>";
?>


 

Posted by bruce lee