dtjo87679 2016-12-13 00:07
浏览 66

将单选按钮值插入SQL

I have this form area:

 <table width="200" cellpadding="5" cellspacing="0" border="0">
      <tr>
         <td><label class="form_text">
            <input type="radio" name="date_pref" value="gregorian" id="date_pref-0">&nbsp; Gregorian</label>
         </td>
      </tr>
      <tr>
           <td><label class="form_text">
                <input type="radio" name="date_pref" value="hebrew" id="date_pref-1">&nbsp; Hebrew</label>
           </td>
     </tr>
 </table>

and the PhP to insert into the SQL table is

 <?php if(isset($_POST['submit'])){
            $email=$_POST['cemail'];
            $password=$_POST['cpass'];
            $cname=$_POST['cname'];
            $dname=$_POST['dname'];
            $dateeng=$_POST['dateenglish'];
            $datehebrew=$_POST['datehebrew'];
            $date_pref=$_POST['date_pref'];
            }

 $table_name='candle_number';

            $wpdb->insert( $table_name, array
  ( 'userid' => $user_id, 'dname' => $dname ,'dateenglish' =>
  $dateeng,'datehebrew' => $datehebrew, 'dateformat' => $date_pref ));

But what is happening now is no result is created. I THINK maybe I am not formatting the radio result correctly for the SQL, but I cannot seem to find a concise answer. the SQL row is formatted as VARCHAR. Any help would be great.

EDIT: The SQL row is

 date format  VARCHAR(10) NULL
  • 写回答

2条回答 默认 最新

  • doskmc7870 2016-12-13 01:19
    关注

    Solved! Just a matter of the right $_POST['date_pref']

    评论

报告相同问题?