使用php从MySQL数据库中的多组单选按钮插入数据

时间:2015-04-01 20:42:55

标签: php html database postgresql radio-button

我正在使用HTML页面中的一些单选按钮 共有3组,其名称为。他们在这里:

teste.php

<?php
session_start();
include "functions.php";
session_checker();
echo "Bem vindo <strong>". $_SESSION['name'] ."</strong>,seu id de usuário é <strong>". $_SESSION['id'] ."</strong> <br/><br/>";

echo "<a href=\"logout.php\">Sair</a>";

?>
<html lang="pt-br">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Teste</title>
<link rel="stylesheet" type="text/css" href="index.css">
</head> 

<body class="body">

<div class="header">Teste</div>
<form name="form" action="gravar.php" method="post" enctype="multipart/form-data">

<div class="Content">
    <ul>
        <a href="mcq.php?test=gre"><li id="b1">Fig 01</li></a> 
        <a href="mcq.php?test=gre"><li id="b2">Fig 02</li></a>
        <a href="mcq.php?test=gre"><li id="b3">Fig 03</li></a>

        <a><li id="b5">
            <input type="radio" name="ola" value="1">Pouco Interessante <p>
            <input type="radio" name="ola" value="2">Moderadamente Interessante <p>
            <input type="radio"s name="ola" value="3">Muito Interessante <p>
        </li></a>
        <a><li id="b6">
            <input type="radio" name="fc" value="4">Pouco Interessante <p>
            <input type="radio" name="fc" value="5">Moderadamente Interessante <p>
            <input type="radio"s name="fc" value="6">Muito Interessante <p>         
        </li></a>

        <a><li id="b7">
            <input type="radio" name="cy" value="7">Pouco Interessante <p>
            <input type="radio" name="cy" value="8">Moderadamente Interessante <p>
            <input type="radio" name="cy" value="9">Muito Interessante <p>              
            </li></a>

        <div>
            <a><li>
            <input type="submit" name="Próximo" value="Próximo" />
                </li></a>
        </div>
    </ul>
</div> 
</form>

然后,我将信息插入PostgreSQL数据库,抛出此文件:

gravar.php

<?php

session_start();
include "functions.php";
session_checker();
if ( isset ( $_POST["ola"] ) ){
$_SESSION['ola'] = $_POST["ola"];
echo "Pegou o o valor da Session: ".$_SESSION['ola']."";

}else{
echo "Erro ao registrar a Session!";
}


include ("conecta.php");

$sql = "INSERT INTO table (id_user, text_radio, id_place) VALUES (". $_SESSION['id'] .", ". $_SESSION['ola'] .", '714');";

$res = pg_exec($sql);

$qtd_linhas = pg_affected_rows($res);

echo "Informacoes gravadas com sucesso!"
?>

但是这样,我只能插入三个单选按钮中的一个。

如何插入三个?

提前致谢。

0 个答案:

没有答案
相关问题