php - Store mutiple select box value and same input field value in serialized form -


<!-- html code --> <form id="wpsc-settings-form" action="" method="post"> <tr class="rate_row"> <td>      <input type="text" style="width:160px;" value="3000" name="zipcode[]"> </td> <td>     <select multiple="" name="city[]">         <option value="abbotsford">abbotsford</option>         <option value="aberfeldie">aberfeldie</option>         <option value="airport west">airport west</option>     </select> </td>  <td>     <input type="text" style="width:160px;" value="3000" name="zipcode[]"> </td> <td>     <select multiple="" name="city[]">         <option value="abbotsford">abbotsford</option>         <option value="aberfeldie">aberfeldie</option>         <option value="airport west">airport west</option>     </select> </td> </tr>     </form> 

enter image description here

<!-- php code --> <?php         $options = $_post['zipcode'];         $city = $_post['city'];           $serializeoption = serialize($city);          foreach($city $key => $value){             $simple_shipping_options_city[$options[$key]] = $value;         }          echo "<pre>";         print_r($simple_shipping_options_city);         echo "</pre>";          update_option('wpsc_simple_shipping_city', $simple_shipping_options_city); // update query ?>   

the code above works following way. if select 1 city output this:

 array ( [3000] => abbotsford [2000] => airport west )   

if select multiple cities not pass input field value.

i want save single zipcode against mutiple city. please provide suggestions of improvements of above code?

for starters, in line

print_r($simple_shipping_options_city); 

simple_shipping_options_city array. need tell array index want see.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -