title: PHP and Jquery - getting array value
body: <p>I have a gallery where the user rates the images. I'm busy trying to get jquery going so it updates without reloading the page. So far, I've managed to get the selected radio button for the rating, so what I'm trying to do now is get the ID of the image, so I can post the rating and image id to a PHP function to handle updating the rating in the database.</p>
  
  <p>My question is, how do I get the image id from the array in PHP, to Jquery?</p>
  
  <p>Using Codeigniter 2.0.3</p>
  
  <p>radio form:</p>
  
  <pre><code>echo form_open('home/rate_image/'.$image['image_id'], array('id' =&gt; 'form_rate');
  
  $counter = 1;
  $form = 1;
  while($counter &lt; 11){
      echo form_radio('rate', $form, FALSE).$form.' ';
      $counter ++;
      $form ++;
  }
  
  echo '&lt;br /&gt;';
  echo form_submit('submit', 'Vote');
  echo form_close();
  </code></pre>
  
  <p>Jquery (which is wonky atm XP):</p>
  
  <pre><code>$(document).ready(function(){
      $('#form_rate').submit(function(e){
              e.preventDefault();
  
          var rating = $("input[name='rate']:checked").val(); 
          var image_id = (*where I want image ID from image array in PHP);
  
          // hide form
          $('#form_rate').hide();
  
          if(rating == null){
              $('#imageContainer').html('Please select a rating before voting');
              $('#form_rate').show();
          }else{
              $('#imageContainer').html('You have selected a rating of '+ rating + ' for the image '+ image_id);
          }
  
          // ajax code to post rating and image_id to update rating
  
      });
  });
  </code></pre>
  
  <p>image id I want to pass to jquery:</p>
  
  <pre><code>$image['image_id']
  </code></pre>