Mayank23 0 Light Poster

I want to make a rating system that uses ajax for the rating.
i use php and call all of the images, then i want to use ajax to post all the votes to a php script. However, i dont know how to get the elements. I want to be able to identify which picture the user selected.

<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        
        
        <a href="upload.html"> Upload pics </a><br/>
        <?php
        
        mysql_connect('localhost','root','');
        mysql_select_db("ajax");
       $query="SELECT * FROM xxxxx";
       $result= mysql_query($query);

       while($row=  mysql_fetch_array($result)){
           
         
echo "<img src =\"" .$row['filepath']."\" /><br/><button name='subject' id='x' type='submit'>".$row['xxxxx']."</button><br/>";
       }
       
   
      
        ?>
            <script type="text/javascript" >
                var x = document.getElementById("x");     I want to be able to identify which picture the user selected. 
             
               
               
             
               if(window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("xxxx").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","tet.php?rating=x",true);
xmlhttp.send();
    </script>
    </body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.