nickbunyun Posted April 23, 2008 Share Posted April 23, 2008 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 More sharing options...
947740 Posted April 23, 2008 Share Posted April 23, 2008 The PHP script. For form submitting, you use $_POST['fieldname'] to retrieve the value of that form field. E.G. <?php $answer1 = $_POST['fieldname']; ?> In your HTML, you need to have the same name for the radio buttons, but you need different values. Link to comment https://forums.phpfreaks.com/topic/102543-radio-group-question/#findComment-525015 Share on other sites More sharing options...
nickbunyun Posted April 23, 2008 Author Share Posted April 23, 2008 im still a lil lost.. Link to comment https://forums.phpfreaks.com/topic/102543-radio-group-question/#findComment-525034 Share on other sites More sharing options...
947740 Posted April 23, 2008 Share Posted April 23, 2008 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 More sharing options...
nickbunyun Posted April 23, 2008 Author Share Posted April 23, 2008 do u mean this ? <input type="radio" name="rate" value="radio" id="rate_0" /> the name to be something differnt? like rate1 rate2 rate3? or is taht the id? man im soo freaking lost and how do i set up my database? Link to comment https://forums.phpfreaks.com/topic/102543-radio-group-question/#findComment-525244 Share on other sites More sharing options...
nickbunyun Posted April 23, 2008 Author Share Posted April 23, 2008 do i create 3 fields for the vote? Link to comment https://forums.phpfreaks.com/topic/102543-radio-group-question/#findComment-525319 Share on other sites More sharing options...
947740 Posted April 23, 2008 Share Posted April 23, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.