title: HTML: Submit star rating into my SQL database
body: <p>I currently have a working review form that the user can write a review about a hotel. So far it takes in a title and body but i now wish to implement a star rating so the user selects a rating and it will submit to my database. I currently have the code where the user can submit the title and body, however the star rating does not submit and does not submit to my database. Can anyone advise ?</p>
  
  <p>ReviewController.php</p>
  
  <pre><code>    public function store(Request $request)
  {
      $this-&gt;validate($request, [
          'title' =&gt; 'required' ,
          'body' =&gt; 'required' ,
          'post_id' =&gt; 'required'
      ]);
  
      $review = new Review;
      $review-&gt;title = $request-&gt;input('title');
      $review-&gt;body = $request-&gt;input('body');
      $review-&gt;rating = $request-&gt;input('rating');
      $review-&gt;post_id = $request['post_id'];
      $review-&gt;save();
      return redirect('/posts')-&gt;with('success', 'post created');
  }
  </code></pre>
  
  <p>Show.blade.php</p>
  
  <pre><code>    &lt;h1&gt;Reviews&lt;/h1&gt;
  @if(count($review) &gt; 1)
      @foreach($review as $reviews)
          &lt;div class= "well"&gt; 
              &lt;h3&gt;&lt;a href="/reviews/{{$reviews-&gt;title}}"&gt;{{$reviews-&gt;title}} &lt;/a&gt;{{$reviews-&gt;rating}}&lt;/h3&gt;&lt;small&gt;{{$reviews-&gt;created_at}}&lt;/small&gt;&lt;br&gt;
              &lt;small&gt;{{$reviews-&gt;body}}&lt;/small&gt; 
             &lt;br&gt;
             &lt;br&gt;
          &lt;/div&gt;
  
          @endforeach
  
          @else
      &lt;/p&gt;no posts found&lt;/p&gt;
      @endif     
  @endsection  
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>var count;
   function starmark(item)
  {
    count=item.id[0];
    sessionStorage.starRating = count;
    var subid= item.id.substring(1);
      for(var i=0;i&lt;5;i++)
        {
          if(i&lt;count)
        {
      document.getElementById((i+1)+subid).style.color="orange";
        }
          else
        {
      document.getElementById((i+1)+subid).style.color="black";
      }
          }
              }
  </code></pre>
  
  <p>When i submit this to my database, the values appear as NULL, however i want them to have a value from 1-5. </p>