Jump to content

radio group question


nickbunyun

Recommended Posts

Ok..

I've made FORMS with just text fields.. and i can make it send in the db.. and than i can view it.

 

But I havnt done anything with radio groups.

 

so I wanna make a feedback form.. and im gonna have a couple of questions as radio group.

 

How do i make them ? (i can do the HTML part).. but how do i set up my php file..

and how do i setup my database?

 

considering im gonna have..

 

lets say something like this

 

<!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>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <label>
  Name: 
  <input type="text" name="name" id="name" />
  </label>
</form>
<form id="form2" name="form2" method="post" action="">
  <p>
    <label> How would you rate us?<br />
    <input type="radio" name="rate" value="radio" id="rate_0" />
    great</label>
    <br />
    <label>
      <input type="radio" name="rate" value="radio" id="rate_1" />
      fair</label>
    <br />
    <label>
      <input type="radio" name="rate" value="radio" id="rate_2" />
      bad</label>
    <br />
  </p>
</form>
</body>
</html>

 

Its gonna be more questions.. but repetitive stuff like that..

Link to comment
https://forums.phpfreaks.com/topic/102543-radio-group-question/
Share on other sites

For your <form> tags, you need an action.  Let's say "test.php".  On "test.php", you have some code to process the form data.

 

E.G.

<?php
$rating = $_POST['rate'];
?>

 

 

You then have to insert the answers into the database.

 

My other point was that, in your second form, all the radio buttons have the same value.  The value needs to be different, and it needs to correspond to the value you want it to have.

Link to comment
https://forums.phpfreaks.com/topic/102543-radio-group-question/#findComment-525048
Share on other sites

Leave all of the names the same.  You know how you have different 'ids' for every radio button?  It is the same concept.  Change the values.

 

E.G.

<input type='radio' name='rate' value='great' />
<input type='radio' name='rate' value='decent' />
<input type='radio' name='rate' value='not_good' />

 

For the MySQL table issue read these:

 

http://www.tech-recipes.com/mysql_tips376.html

http://dev.mysql.com/doc/refman/5.0/en/data-types.html

 

For the last link, you will want to look at the different data types.

Link to comment
https://forums.phpfreaks.com/topic/102543-radio-group-question/#findComment-525544
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.