title: How to store multiple fields data into same variable using php?
body: <p>I am new to PHP. I have a form in which I used <code>input type text</code> now I want to store multiple field data into same column of mysql db.</p>
  
  <p><a href="https://i.stack.imgur.com/7G8XD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7G8XD.png" alt="enter image description here"></a></p>
  
  <p>For example, according to above picture i want to store all opinions in one column, all rating types in one column and so on.</p>
  
  <p>I googled for this problem, and I found implode as the solution. But I don't know how I can use it.</p>
  
  <pre><code>&lt;table width="800" height="194" border="1" &gt;
    &lt;tr&gt; &lt;td&gt;Id&lt;/td&gt; 
    &lt;td colspan="8"&gt;&lt;input type="text" name="company_id" value="&lt;?php echo $row['pr_client']?&gt;" size="5" readonly/&gt; &lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;
              &lt;td width="234" rowspan="3"&gt;&lt;b&gt;Opinion&lt;/b&gt;&lt;/td&gt;
              &lt;td width="129" rowspan="3"&gt;&lt;b&gt;Rating Type&lt;/b&gt;&lt;/td&gt;
              &lt;td width="74" rowspan="3"&gt;&lt;b&gt;Action&lt;/b&gt;&lt;/td&gt;
              &lt;td width="89" rowspan="3"&gt;&lt;b&gt;Outlook&lt;/b&gt;&lt;/td&gt;
              &lt;td height="58" colspan="4"&gt;&lt;div align="center"&gt;&lt;b&gt;              Ratings            &lt;/b&gt;&lt;/div&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td colspan="2"&gt;&lt;div align="center"&gt;&lt;b&gt;           Long Term   &lt;/b&gt;      &lt;/div&gt;&lt;/td&gt;
            &lt;td colspan="2"&gt;&lt;div align="center"&gt;  &lt;b&gt;     Short Term  &lt;/b&gt;      &lt;/div&gt;&lt;/td&gt;
    &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td width="55"&gt;&lt;b&gt;Current&lt;/b&gt;&lt;/td&gt;
            &lt;td width="62"&gt;&lt;b&gt;Previous&lt;/b&gt;&lt;/td&gt;
            &lt;td width="55"&gt;&lt;b&gt;Current&lt;/b&gt;&lt;/td&gt;
            &lt;td width="66"&gt;&lt;b&gt;Previous&lt;/b&gt;&lt;/td&gt;
        &lt;/tr&gt;
          &lt;tr&gt;
           &lt;td width="234" rowspan="2"&gt;&lt;input type="text" name="first_opinion_name" value="&lt;?php echo $row['opinion']?&gt;" size="32"/&gt;&lt;/td&gt;
           &lt;td width="129" rowspan="2"&gt;&lt;input type="text" name="first_opinion_rating_type" value="&lt;?php echo $row['ttitle'] ?&gt;" 
            size="10"/&gt;&lt;/td&gt;
          &lt;td width="74" rowspan="2"&gt;&lt;input type="text" name="first_opinion_action" value="&lt;?php echo $row['atitle'] ?&gt;" size="06"/&gt;&lt;/td&gt;
          &lt;td width="89" rowspan="2"&gt;&lt;input type="text" name="first_opinion_outlook" value="&lt;?php echo $row['otitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
             &lt;tr&gt;
            &lt;td width="55"&gt;&lt;input type="text" name="first_opinion_long_term" value="&lt;?php echo $row['ltitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
            &lt;td width="62"&gt;&lt;input type="text" name="first_opinion_p_long_term" value="&lt;?php echo $row1['ltitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
            &lt;td width="55"&gt;&lt;input type="text" name="first_opinion_short_term" value="&lt;?php echo $row['stitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
            &lt;td width="62"&gt;&lt;input type="text" name="first_opinion_p_short_term" value="&lt;?php echo $row1['stitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
  
  
          &lt;tr&gt;
          &lt;td width="234" rowspan="2"&gt;&lt;input type="text" name="second_opinion_name" value="&lt;?php echo $row2['opinion']?&gt;" size="32"/&gt;&lt;/td&gt;
          &lt;td width="129" rowspan="2"&gt;&lt;input type="text" name="second_opinion_rating_type" value="&lt;?php echo $row2['ttitle'] ?&gt;" 
            size="10"/&gt;&lt;/td&gt;
         &lt;td width="74" rowspan="2"&gt;&lt;input type="text" name="second_opinion_action" value="&lt;?php echo $row2['atitle'] ?&gt;" size="06"/&gt;&lt;/td&gt;
        &lt;td width="89" rowspan="2"&gt;&lt;input type="text" name="second_opinion_outlook" value="&lt;?php echo $row2['otitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
             &lt;tr&gt;
            &lt;td width="55"&gt;&lt;input type="text" name="second_opinion_long_term" value="&lt;?php echo $row2['ltitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
            &lt;td width="62"&gt;&lt;input type="text" name="second_opinion_p_long_term" value="&lt;?php echo $row3['ltitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
            &lt;td width="55"&gt;&lt;input type="text" name="second_opinion_short_term" value="&lt;?php echo $row2['stitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
            &lt;td width="62"&gt;&lt;input type="text" name="second_opinion_p_short_term" value="&lt;?php echo $row3['stitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
                        &lt;/tr&gt;
  
  
            &lt;tr&gt;
      &lt;td width="234" rowspan="2"&gt;&lt;input type="text" name="third_opinion_name" value="&lt;?php echo $row4['opinion']?&gt;" size="32"/&gt;&lt;/td&gt;
    &lt;td width="129" rowspan="2"&gt;&lt;input type="text" name="third_opinion_rating_type" value="&lt;?php echo $row4['ttitle'] ?&gt;"size="10"/&gt;&lt;/td&gt;
    &lt;td width="74" rowspan="2"&gt;&lt;input type="text" name="third_opinion_action" value="&lt;?php echo $row4['atitle'] ?&gt;" size="06"/&gt;&lt;/td&gt;
    &lt;td width="89" rowspan="2"&gt;&lt;input type="text" name="third_opinion_outlook" value="&lt;?php echo $row4['otitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
             &lt;tr&gt;
            &lt;td width="55"&gt;&lt;input type="text" name="third_opinion_long_term" value="&lt;?php echo $row4['ltitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
            &lt;td width="62"&gt;&lt;input type="text" name="third_opinion_p_long_term" value="&lt;?php echo $row5['ltitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
            &lt;td width="55"&gt;&lt;input type="text" name="third_opinion_short_term" value="&lt;?php echo $row4['stitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
            &lt;td width="62"&gt;&lt;input type="text" name="third_opinion_p_short_term" value="&lt;?php echo $row5['stitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
  
            &lt;/tr&gt;
  
            &lt;tr&gt;
    &lt;td width="234" rowspan="2"&gt;&lt;input type="text" name="forth_opinion_name" value="&lt;?php echo $row6['opinion']?&gt;" size="32"/&gt;&lt;/td&gt;
    &lt;td width="129" rowspan="2"&gt;&lt;input type="text" name="forth_opinion_rating_type" value="&lt;?php echo $row6['ttitle'] ?&gt;"size="10"/&gt;&lt;/td&gt;
    &lt;td width="74" rowspan="2"&gt;&lt;input type="text" name="forth_opinion_action" value="&lt;?php echo $row6['atitle'] ?&gt;" size="06"/&gt;&lt;/td&gt;
    &lt;td width="89" rowspan="2"&gt;&lt;input type="text" name="forth_opinion_outlook" value="&lt;?php echo $row6['otitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
             &lt;tr&gt;
            &lt;td width="55"&gt;&lt;input type="text" name="forth_opinion_long_term" value="&lt;?php echo $row6['ltitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
            &lt;td width="62"&gt;&lt;input type="text" name="forth_opinion_p_long_term" value="&lt;?php echo $row7['ltitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
            &lt;td width="55"&gt;&lt;input type="text" name="forth_opinion_short_term" value="&lt;?php echo $row6['stitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
            &lt;td width="62"&gt;&lt;input type="text" name="forth_opinion_p_short_term" value="&lt;?php echo $row7['stitle'] ?&gt;" size="05"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
  
            &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>My Php Code is</p>
  
  <pre><code>$first_opinion_name = $_POST['first_opinion_name'];
  $first_opinion_rating_type = $_POST['first_opinion_rating_type'];
  $first_opinion_action = $_POST['first_opinion_action'];
  $first_opinion_outlook = $_POST['first_opinion_outlook'];
  $first_opinion_long_term = $_POST['first_opinion_long_term'];
  $first_opinion_p_long_term = $_POST['first_opinion_p_long_term'];
  $first_opinion_short_term = $_POST['first_opinion_short_term'];
  $first_opinion_p_short_term = $_POST['first_opinion_p_short_term'];
  
  $second_opinion_name = $_POST['second_opinion_name'];
  $second_opinion_rating_type = $_POST['second_opinion_rating_type'];
  $second_opinion_action = $_POST['second_opinion_action'];
  $second_opinion_outlook = $_POST['second_opinion_outlook'];
  $second_opinion_long_term = $_POST['second_opinion_long_term'];
  $second_opinion_p_long_term = $_POST['second_opinion_p_long_term'];
  $second_opinion_short_term = $_POST['second_opinion_short_term'];
  $second_opinion_p_short_term = $_POST['second_opinion_p_short_term'];
  
  $third_opinion_name = $_POST['third_opinion_name'];
  $third_opinion_rating_type = $_POST['third_opinion_rating_type'];
  $third_opinion_action = $_POST['third_opinion_action'];
  $third_opinion_outlook = $_POST['third_opinion_outlook'];
  $third_opinion_long_term = $_POST['third_opinion_long_term'];
  $third_opinion_p_long_term = $_POST['third_opinion_p_long_term'];
  $third_opinion_short_term = $_POST['third_opinion_short_term'];
  $third_opinion_p_short_term = $_POST['third_opinion_p_short_term'];
  
  $forth_opinion_name = $_POST['forth_opinion_name'];
  $forth_opinion_rating_type = $_POST['forth_opinion_rating_type'];
  $forth_opinion_action = $_POST['forth_opinion_action'];
  $forth_opinion_outlook = $_POST['forth_opinion_outlook'];
  $forth_opinion_long_term = $_POST['forth_opinion_long_term'];
  $forth_opinion_p_long_term = $_POST['forth_opinion_p_long_term'];
  $forth_opinion_short_term = $_POST['forth_opinion_short_term'];
  $forth_opinion_p_short_term = $_POST['forth_opinion_p_short_term'];
  
  
  $query = mysql_query("INSERT INTO letter(to_name, to_designation, company, address, confidential, date, rating_type_title, opinion_type, dear_sir, company_id, first_opinion_name, first_opinion_rating_type, first_opinion_action, first_opinion_outlook, first_opinion_long_term, first_opinion_p_long_term, first_opinion_short_term, first_opinion_p_short_term, second_opinion_name, second_opinion_rating_type, second_opinion_action, second_opinion_outlook, second_opinion_long_term, second_opinion_p_long_term, second_opinion_short_term, second_opinion_p_short_term, third_opinion_name, third_opinion_rating_type, third_opinion_action, third_opinion_outlook, third_opinion_long_term, third_opinion_p_long_term, third_opinion_short_term, third_opinion_p_short_term, forth_opinion_name, forth_opinion_rating_type, forth_opinion_action, forth_opinion_outlook, forth_opinion_long_term, forth_opinion_p_long_term, forth_opinion_short_term, forth_opinion_p_short_term, y_truly, s_name, uh1, uh2, uh1_designation, uh2_designation, s_designation, chk, chk1)
  
  values 
  
  ('$to_name', '$to_designation', '$company', '$address', '$confidential', '$Date', '$rating_type_title', '$opinion_type', '$dear_sir', '$company_id', '$first_opinion_name', '$first_opinion_rating_type', '$first_opinion_action', '$first_opinion_outlook', '$first_opinion_long_term', '$first_opinion_p_long_term', '$first_opinion_short_term', '$first_opinion_p_short_term', '$second_opinion_name', '$second_opinion_rating_type', '$second_opinion_action', '$second_opinion_outlook', '$second_opinion_long_term', '$second_opinion_p_long_term', '$second_opinion_short_term', '$second_opinion_p_short_term', '$third_opinion_name', '$third_opinion_rating_type', '$third_opinion_action', '$third_opinion_outlook',  '$third_opinion_long_term', '$third_opinion_p_long_term', '$third_opinion_short_term', '$third_opinion_p_short_term', '$forth_opinion_name', '$forth_opinion_rating_type', '$forth_opinion_action', '$forth_opinion_outlook',  '$forth_opinion_long_term', '$forth_opinion_p_long_term', '$forth_opinion_short_term', '$forth_opinion_p_short_term', '$y_truly', '$s_name', '$uh1', '$uh2', '$uh1_designation', '$uh2_designation', '$s_designation', '$chk', '$chk1')");
  
  echo "&lt;br/&gt;&lt;br/&gt;&lt;span&gt;Data Inserted successfully...!!&lt;/span&gt;";
  
  
  
  
  }
  ?&gt;
  </code></pre>
  
  <p>Can you please help me?</p>