Link to home
Start Free TrialLog in
Avatar of pc-buddy
pc-buddy

asked on

PHP Radio Array

Hi,

I have a DB query thats pulling many rows from a table, each row has an id and an email address, firstname and lastname, I'm trying to print out the query showing each row, then once i have this let the user select 1 of 3 radios buttons,
1. for wipes
2. nappies
3. both

once they have selected for each row then submit the form, if they have choosen radio button 1 i want to run one selection of code, if they have selected radio button 2 for nappies i want to run another selection or code for those rows.

the code below shows what i'm printing out for each row from the db, but how do I do a foreach when submited and break them apart, i'll need the ID or the email address passed through to know who going for what option ?, they can only select one option per row so i'm using radio buttons.

<form name='form1' id='form1' method='post' action=''>
        <?php while($row = mysql_fetch_array($retval, MYSQL_ASSOC)){ ?>
        <div>
          <div style="float:left; width:160px"><?php echo $row['child_firstname'] . " " . $row['child_lastname']; ?></div>
          <div style="float:left; width:100px">
             <input type="radio" name="item[<?php echo $row['id']; ?>]" value="wipes">
          </div>
          <div style="float:left; width:100px">
            <input type="radio" name="item[<?php echo $row['id']; ?>]" value="nappies">
          </div>
          <div style="float:left; width:100px">
            <input type="radio" name="item[<?php echo $row['id']; ?>]" value="both">
          </div>
          <div style="clear:both"></div>
        </div>
        <?php } ?>

Open in new window


Thanks Simon
SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pc-buddy
pc-buddy

ASKER

Hi Julian,

I'll go have a play, thanks :)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Awesome help, thanks guys