Jump to content

[SOLVED] while with radio buttons... help!!


ebaretta

Recommended Posts

<?php while ($row=mysql_fetch_assoc($result) {
<?php if ($row['sub_cat'] == '1') { ?><label><input name="Default" type="radio" id="Default[]" value="1" checked="checked" />
		  Default</label><br /><?php } else { ?><label><input name="Default" type="radio" id="Default[]" value="1" />
		  Default</label><br /><?php }
          	
          if ($row['sub_cat'] == '2') { ?><label><input type="radio" name="sub_cat" value="2" id="<?php echo $pic_id.'sub_cat[]';?>" checked="checked"/>
          Inside</label><br /><?php } else { ?><label><input type="radio" name="sub_cat" value="2" id="<?php echo $pic_id.'sub_cat[]';?>"/>
          Inside</label><br /><?php }
        
          if ($row['sub_cat'] == '3') { ?><label><input type="radio" name="sub_cat" value="3" id="<?php echo $pic_id.'sub_cat[]';?>" checked="checked"/>
          Outside</label><br /><?php } else { ?><label><input type="radio" name="sub_cat" value="3" id="<?php echo $pic_id.'sub_cat[]';?>"/>
          Outside</label><br /><?php }
        
          if ($row['sub_cat'] == '4') { ?><label><input type="radio" name="sub_cat" value="4" id="<?php echo $pic_id.'sub_cat[]';?>" checked="checked"/>
          Blue Print</label><br /><?php } else { ?><input type="radio" name="sub_cat" value="4" id="<?php echo $pic_id.'sub_cat[]';?>"/>
          Blue Print</label><br /><?php } ?>
<?php } ?>

 

All this does is create the table structure for each row called sets the one that is suppose to be default to default. However in the other 3 radio buttons (Inside, Outside, and BluePrint) only the last table has the correct one checked. I reviewed over the source code and it had all the ones checked that was suppose to be checked yet it did not show up in the page. I have tried every combination i can think of in order to get it to work.

$pic_id calls a number so the id for the radio buttons looks like id="8sub_cat[]", id="9sub_cat[]" for each individual table.

Link to comment
Share on other sites

Ok, I'm confused.  Usually the id field is for css formating or js scripts.  Why are you using [] like an array?

 

The name field is the posting variable.

 

Are you posting then updating the table?

 

Link to comment
Share on other sites

$pic_id is the id of the pic that is pulled from the database so that once the form is submitted it will be able to distinguish which ones go where for which pic...

 

Here i'm pulling the pic_id out just to give the radio button array a unique name automatically without me having to use other coding... each pic has the option of being inside, outside or a blueprint picture(but only one of these options) also out of all the pictures only 1 in the whole group can be a default picture. so basically if you have 3 picutes 1 will be default and maybe the other two are inside picutes but once i submit the information into the file i will need to distinguish between which ones are inside and which are outside and which are blue prints and which one is default. (this is usually done with about 10 pictures or so.) and yes your right about the name field... My main concern is when i pull up the page nothing is "checked" right. However if i look at the source code everything that is suppose to be checked is checked in the code... that is in every browser.. ie, firefox, opera, safari...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.