radio button or list/menu

It doesn't matter if you do all the error checking in the world, or if you have the most beautiful graphics, if your site or application design isn't usable, it's not going to do well. Get input and advice on usability and user interface issues here.

Moderator: General Moderators

Post Reply
stubbykiller
Forum Newbie
Posts: 2
Joined: Tue Jan 13, 2009 9:15 am

radio button or list/menu

Post by stubbykiller »

~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


hi everyone. im new in php. i am designing a survey application using php and mysql...

i have a problem with radio button and list/menu.

Code: Select all

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
 
<body>
<table width="800" border="1" cellpadding="0" cellspacing="0">
  <form id="form1" name="form1" method="post" action="main.php">
  <tr>
    <td width="132">Control No.:</td>
    <td width="144">
      <input type="text" name="ctrl_no" id="ctrl_no" />    </td>
    <td width="183">&nbsp;</td>
    <td width="155">&nbsp;</td>
    <td width="174">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  <td>&nbsp;</td>
   <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <?php while($r_cat = mysql_fetch_assoc($result)) { ?>
  <tr>
    <td>&nbsp;</td>
    <td><?php echo $r_cat['cat_name'];?>
      <input name="dept_id" type="hidden" id="dept_id" value="<?php echo $r_cat['dept_id'];?>" />
      <input name="cat_id" type="hidden" id="cat_id" value="<?php echo $r_cat['cat_id'];?>" />      </td>
    <td>
    <select name="score" id="score">
    <option value=" " selected="selected"> </option>
    <?php $q_score = "select * from score";
              $score_result = mysql_query($q_score) or die(mysql_error());
              while($r_score = mysql_fetch_assoc($score_result)){
            
            if($r_score['score_id'] == 'score_id')
             {
              $selected = " selected";
             } 
            else
             {
              $selected = "";
             } 
         echo '<option value="'. $r_score['score_id'] . '"'.$selected.'>'. $r_score['comm_name'].
              '</option>'."\r\n";    
      
    } ?>
    </select>    </td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  
  <tr>
    <td>&nbsp;</td>
    <td><input type="radio" name="score2" id="radio" value="3" />Delighted</td>
    <td><input type="radio" name="score2" id="radio" value="1.5" />Satisfied</td>
    <td><input type="radio" name="score2" id="radio" value="-2" />Disappointed</td>
  </tr><?php }//end while ($r_cat = mysql_fetch_assoc($result)) ?>
  <tr>
   <td>&nbsp;</td>
   <td><input type="submit" name="Post" id="Post" value="Post" /></td>
   <td><input type="submit" name="Cancel" id="Cancel" value="Cancel" /></td>
  </tr>
  </form>
</table>
 
 
</body>
</html>

here is my code.. i have a problem how will i insert the looped radio or list menu to the database. will i make an array for this... pls help me.........


~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.
stubbykiller
Forum Newbie
Posts: 2
Joined: Tue Jan 13, 2009 9:15 am

Re: radio button or list/menu

Post by stubbykiller »

to simplify things.. this is how my survey looks like.
note: the '0's bellow is the radio button

category comment
security 0delighted 0satisfied 0disappointed
bell service 0delighted 0satisfied 0disappointed
parking 0delighted 0satisfied 0disappointed



how will i insert the value of these radio button in the dbase?? the category column came from the database and so as the comment..

can someone help me how will i insert the value of the radion button in the database. i tried to insert it and it inserts a 0 value..
Post Reply