Insert using radio button

I have 2 radio buttons i.e., outstation and city. On click of city table containing 2 tabs open namely round trip and one way whereas on click of outstation a table opens containing all the required field. Now all I want is, on selection of radio button value it must insert into database table. As of now, all the fields are getting inserted regardless of selection. I tried using if else condition as well as flag but no luck.
Any help will be great!!!
Below is the code:

 <table style="max-width:850px" border="0" cellspacing="0" cellpadding="0"  align="left" id ="data_table">                                                        <tr>
                                                            <td colspan="4">&nbsp;</td>
                                                        </tr>
                                                        <tr>
                                                            <td width="110">Type of Trip</td>
                                                            <td width="140">
                                                                <div align="left">                                                               
                                                                    Outstation: <input type="radio" onclick="javascript:taxi_booking();" name="yesno" id="city" checked="checked" value="outstation">
                                                                </div>
                                                            </td>
                                                            <td width="140">
                                                                <div align="left">
                                                                    City Local: <input type="radio" onclick="javascript:taxi_booking();" name="yesno" id="outstation" value="city"> 
                                                                    <br>    
                                                                </div>
                                                            </td></tr></table>

table for city:

                                                            <div id="tabs-1">
                                                                <table style="max-width:880px" border="1" bordercolor="#c1dde4" cellspacing="0" cellpadding="5" id="roundtrip_tbl_travel">
                                                                    <tr class="accombg">
                                                                        <td colspan="4" align="center"><strong>Round City Local Travel</strong></td>
                                                                        <td colspan="4" align="center"><strong>Date and Time </strong></td>
                                                                        <!-- <td rowspan="2" style="min-width:110px;max-width:120px;" align="center"><strong>Travel Mode (Airport PickUp/Drop) </strong></td> -->
                                                                    </tr>

                                                                    <tr class="accombg">
                                                                        <td align="center">Origin <span class="redtext">* </span >
                                                                            <p><span class="accombgsmalltext"> (Enter country if foreign, City if India)</span></p>
                                                                        </td>
                                                                        <td align="center">Pick Up Point <span class="redtext">*</span><p><span class="accombgsmalltext"> (If Foreign)</span></p></td>
                                                                        <td align="center">Destination <span class="redtext">*</span><p><span class="accombgsmalltext">(Enter country if foreign, City if India)</span></p></td>
                                                                        <td align="center">Drop Point <span class="redtext">*</span><p><span class="accombgsmalltext"> (If Foreign)</span></p></td>
                                                                        <td style="min-width:50px;max-width:50px" align="center">Departure<span class="redtext">*</span></td>
                                                                        <td width="60" align="center">Time</td>
                                                                        <td style="min-width:50px;max-width:50px;" align="center">Arrival <span class="redtext">*</span></td>
                                                                        <td width="60" align="center">Time</td>
                                                                    </tr>

                                                                    <tr class="sectionbg" id="jsTravelRoundDet">
                                                                        <td>
                                                                            <div>
                                                                                
                                                                                <input type="text" size="10" name="round_travel_det[dep_place][]" id="dep_place" readonly="readonly" value="<?php echo $emp_det['location']; ?>" class="jsTravelCls jsCityCls"/>
                                                                            </div>
                                                                        </td>

                                                                        <td>
                                                                            <input type="text"  name="round_travel_det[dep_city][]" id="dep_city" style="width:80px;"  class="jsTravelCls" />
                                                                        </td>

                                                                        <td>
                                                                            <div>
                                                                                <select name="round_travel_det[arr_place][]" style="width:110px;" onchange="showForm19(this.value, this, 'arr_place');" id="arr_place" class="jsTravelCls jsCityCls">
                                                                                    <?php 
                                                                                    $label = ''; $group = 0;
                                                                                    foreach ($city_list as $key => $value) { ?>
                                                                                        <?php if($label == '' || $value['group_name'] != $label) { ?>
                                                                                            <?php if($group) { ?>
                                                                                            </optgroup>
                                                                                        <?php } ?>
                                                                                        <optgroup label="<?php echo ($value['group_name'] == 'INDIA') ? 'DOMESTIC': $value['group_name']; ?>" class="grey">
                                                                                            <?php
                                                                                            $group ++;
                                                                                            $label = $value['group_name'];
                                                                                        }
                                                                                        ?>
                                                                                        <option <?php echo (in_array($value['name'], $city_sens)) ? "style='color:red'" : ''; ?> value="<?php echo $key ?>" ><?php echo $value['name'] ?> 
                                                                                    </option>
                                                                                <?php } ?> 
                                                                                <optgroup label="Others">
                                                                                    <option value="Others">Others</option>
                                                                                </optgroup>
                                                                            </select>
                                                                        </div>
                                                                    </td>

                                                                    <td>
                                                                        <input type="text" name="round_travel_det[arr_city][]" id="arr_city" style="width:80px;"  class="jsTravelCls"/>
                                                                    </td>
                                
                                                                    <td>
                                                                        
                                                                        <input style="min-width:80px;max-width:80px" type="text" name="round_travel_det[dep_date][]" value="" id="assigned_date" class="assigned_date" />
                                                                    </td>

                                                                    <td>
                                                                        <div>
                                                                            <select name="round_travel_det[time_zone1][]" style="max-width:50px"  class="jsTravelCls">
                                                                                <?php
                                                                                    foreach ($time_zone as $tme_zone) {
                                                                                        echo "<option value=\"" . $tme_zone . "\">" . $tme_zone . "</option>";
                                                                                    }
                                                                                ?>
                                                                            </select>
                                                                        </div>
                                                                    </td>

                                                                    <td>
                                                                        <input style="min-width:80px;max-width:80px" type="text" name="round_travel_det[arr_date][]" value="" id="last_date" class="assigned_date" />
                                                                    </td>

                                                                    <td>
                                                                        <div id="tz2">
                                                                            <select name="round_travel_det[time_zone2][]" style="width:50px" class="jsTravelCls"><?php
                                                                            foreach ($time_zone as $tme_zone) {
                                                                                echo "<option value=\"" . $tme_zone . "\">" . $tme_zone . "</option>";
                                                                            }
                                                                            ?> 
                                                                            </select> 
                                                                        </div>
                                                                    </td>

                                                                    
                                                            </tr>
                                                        </table>

                                                        <table>
                                                            <tr>
                                                                <td>
                                                                    <p id="addnew">
                                                                        <a href="javascript:void(0)" class="addlinks" onclick="addTravelRow_1()"> + Insert Row </a> 
                                                                    </p>
                                                                </td>

                                                                <td>
                                                                    <p id="delrow_t" >
                                                                        <a href="javascript:void(0)" class="addlinks" onclick="delIt('roundtrip_tbl_travel')"> - Delete Row </a>
                                                                    </p>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </div>

                                                    <div id="tabs-2">
                                                        <table style="max-width:880px" border="1" bordercolor="#c1dde4" cellspacing="0" cellpadding="5" id="oneway_tbl_travel">
                                                            <tr class="accombg">
                                                                <td colspan="4" align="center"><strong>One Way Travel</strong></td>
                                                                <td colspan="4" align="center"><strong>Date and Time </strong></td>
                                                                
                                                            </tr>

                                                            <tr class="accombg">
                                                                <td align="center">Origin <span class="redtext">* </span ><p><span class="accombgsmalltext">(Enter country if foreign, City if India)</span></p></td>
                                                                <td align="center">City Pick Up<span class="redtext">*</span><p><span class="accombgsmalltext"> (Pick up Point)</span></p></td>
                                                                <td align="center">Destination <span class="redtext">*</span></span><p><span class="accombgsmalltext">(Enter country if foreign, City if India)</span></p></td>
                                                                <td align="center">City Drop Off <span class="redtext">*</span><p><span class="accombgsmalltext"> (Drop Point)</span></p></td>
                                                                <td style="min-width:50px;max-width:50px" align="center">Departure<span class="redtext">*</span></td>
                                                                <td width="60" align="center">Time</td>
                                                                <td style="min-width:50px;max-width:50px;" align="center">Arrival <span class="redtext">*</span></td>
                                                                <td width="60" align="center">Time</td>
                                                            </tr>

                                                            <tr class="sectionbg" id="jsTravelOneWayDet">
                                                                <td>
                                                                    <div>                                                                            
                                                                        <input type="text" size="10" name="oneway_travel_det[dep_place][]" id="dep_place" readonly="readonly" value="<?php echo $emp_det['location']; ?>" class="jsTravelCls jsCityCls"/>

                                                                    </div>
                                                                </td>

                                                                <td>
                                                                    <input type="text" name="oneway_travel_det[dep_city][]" id="dep_city" style="width:80px;"  class="jsTravelCls" />
                                                                </td>

                                                                <td>
                                                                    <div>
                                                                        <input type="text" size="10" name="oneway_travel_det[dep_place][]" id="dep_place" readonly="readonly" value="<?php echo $emp_det['location']; ?>" class="jsTravelCls jsCityCls"/>                                                               
                                                                    </div>
                                                                </td>

                                                                <td>
                                                                    <input type="text"  name="oneway_travel_det[arr_city][]" id="arr_city" style="width:80px;"  class="jsTravelCls"/>
                                                                </td>

                                                                <td>
                                                                    <input style="min-width:80px;max-width:80px" type="text" name="oneway_travel_det[dep_date][]" value="" id="assigned_date" class="assigned_date" />
                                                                </td>

                                                                <td>
                                                                    <div>
                                                                        <select name="oneway_travel_det[time_zone1][]" style="max-width:50px"  class="jsTravelCls"> 
                                                                            <?php
                                                                                foreach ($time_zone as $tme_zone) {
                                                                                    echo "<option value=\"" . $tme_zone . "\">" . $tme_zone . "</option>";
                                                                                }
                                                                            ?>
                                                                        </select>
                                                                    </div>
                                                                </td>

                                                                <td>
                                                                    <input style="min-width:80px;max-width:80px" type="text" name="oneway_travel_det[arr_date][]" value="" id="last_date" class="assigned_date" />
                                                                </td>

                                                                <td>
                                                                    <div id="tz2">
                                                                        <select name="oneway_travel_det[time_zone2][]" style="width:50px" class="jsTravelCls">
                                                                        <?php
                                                                        foreach ($time_zone as $tme_zone) {
                                                                            echo "<option value=\"" . $tme_zone . "\">" . $tme_zone . "</option>";
                                                                        }
                                                                        ?>
                                                                        </select>
                                                                    </div>
                                                                </td>                                                       
                                                            </tr>
                                                        </table>
                                                    </div>
                                                </div>
                                                
                                            </td>
                                            <script type="text/javascript">
                                                $( function() {
                                                    $( "#ifOutstation" ).tabs();
                                                });
                                            </script>
                                        </tr>

table for outstation

<tr>
       <td>
       <div id="city_pickup">
       <table style="max-width:880px" border="1" bordercolor="#c1dde4" cellspacing="0" cellpadding="5" id="tbl_travel">
        <tr class="accombg">
        <td colspan="4" align="center"><strong>Outstation Travel</strong></td>
        <td colspan="4" align="center"><strong>Date and Time </strong></td>
         </tr>
         <tr class="accombg">
         <td align="center">Origin <span class="redtext">* </span></td>
        <td align="center">Origin City <span class="redtext">*</span><p><span class="accombgsmalltext"></span></p></td>
      <td align="center">Destination <span class="redtext">*</span></td>
        <td align="center">Destination City<span class="redtext">*</span><p><span class="accombgsmalltext"></span></p></td>
     <td style="min-width:50px;max-width:50px" align="center">Departure<span class="redtext">*</span></td>
     <td width="60" align="center">Time</td>
      <td style="min-width:50px;max-width:50px;" align="center">Arrival <span class="redtext">*</span></td>
    <td width="60" align="center">Time</td>
                                                                       
                  </tr>

                   <tr class="sectionbg" id="jsTravelDet">
                        <td>
                             <div>
                                 <input type="text" size="10" name="travel_det[dep_place][]" id="dep_place" readonly="readonly" value="<?php echo $emp_det['location']; ?>" class="jsTravelCls jsCityCls"/>
                             </div>
                   </td>
                  <td>
                    <input type="text" name="travel_det[dep_city][]" id="dep_city" style="width:80px;"  class="jsTravelCls" />
                  </td>

                   <td>
                   <select name="travel_det[arr_place][]" style="width:110px;" id="arr_place" onchange="showForm19(this.value, this, 'arr_place');" class="jsTravelCls jsCityCls" >
                          <?php $label = ''; $group = 0; ?>
                            <?php foreach ($city_list as $key => $value) { ?>
                            <?php if($label == '' || $value['group_name'] != $label) { ?>
                              <?php if($group) { ?>
                               </optgroup>
                               <?php } ?>
                             <optgroup label="<?php echo ($value['group_name'] == 'INDIA') ? 'DOMESTIC': $value['group_name']; ?>" class="grey">
                                 <?php
                                           $group ++;
                                          $label = $value['group_name'];
                                  } ?>
                              <option <?php echo (in_array($value['name'], $city_sens)) ? "style='color:red'" : ''; ?> value="<?php echo $key ?>" ><?php echo $value['name'] ?> 
                             </option>
                           <?php } ?>
                               <optgroup label="Others">
                                   <option value="Others">Others</option>
                               </optgroup>
                     </select>
                </td>

             <td>
                <input type="text" name="travel_det[arr_city][]" id="arr_city" style="width:80px;"  class="jsTravelCls"/>
            </td>

      <td>
        <input style="min-width:80px;max-width:80px" type="text" name="travel_det[dep_date][]" value="" id="assigned_date" class="assigned_date" />
    </td>

  <td>
     <div>
        <select name="travel_det[time_zone1][]" style="max-width:50px"  class="jsTravelCls">
              <?php
                 foreach ($time_zone as $tme_zone) {
                     echo "<option value=\"" . $tme_zone . "\">" . $tme_zone . "</option>";
                    }
       ?> 
          </select>
         </div>
      </td>

      <td>
       <input style="min-width:80px;max-width:80px" type="text" name="travel_det[arr_date][]" value="" id="last_date" class="assigned_date" />
      </td>

      <td>
     <div id="tz2">
      <select name="travel_det[time_zone2][]" style="width:50px" class="jsTravelCls">
       <?php
           foreach ($time_zone as $tme_zone) {
           echo "<option value=\"" . $tme_zone . "\">" . $tme_zone . "</option>";
         }
        ?> 
              </select>
          </div>
     </td>

                                                                      
   </tr>
 </table>
   </div>
  </td>
</tr>

Well, not sure of what you are asking as you did not show us your code.
Normally, if you are using a radio button you name it the same name. Something like:
< input type=‘radio’ name=‘sex’ value=‘male’>
< input type=‘radio’ name=‘sex’ value=‘female’>
And, then when the page is posted you get the value as:
$sex = filter_input(INPUT_POST, ‘sex’);
and the value is either male or female and then you can check it and handle as needed.

Not sure if that is what you are asking, but, hope it helps…

Sponsor our Newsletter | Privacy Policy | Terms of Service