Anchor Link值继续传递我的数据库的第一行

时间:2014-07-10 03:09:57

标签: javascript php html ajax

我需要一些建议/帮助。我可以使用ajax将这两个值传递给链接中的其他页面,但是传递的值始终是我数据库的第一行。如果有人可以在这里提供帮非常感谢。

    <script language="javascript" type="text/javascript">
    var httpObject=false;
    if(window.XMLHttpRequest){
        httpObject = new XMLHttpRequest();
    }else if(window.ActiveXObject){
        httpObject = new ActiveXObject("Microsoft.XMLHttp");
    }

    function ajax_post(){

        var data1= document.getElementById('add').value;
        var data2= document.getElementById('csg').value;
        var queryString = "?data1=" + data1;
        queryString +=  "&data2=" + data2;

        httpObject.onreadystatechange = function(){
            if(httpObject.readyState == 4 && httpObject.status == 200){
                var error = document.getElementById('error');
                var response = httpObject.responseText;

                alert(response);
            }
        }
        httpObject.open("GET", "espaceproductinsert.php"+queryString ,true);
        httpObject.send(null);
    }
    </script>




      $sql = mysql_query ("SELECT  * FROM espaceproduct WHERE email = 'jaychou@hotmail.com' ");


      ?>


      <?php   
      $result1  = array();      
      $result2  = array();
      $loopCount1 = 0;        
      $loopCount2 = 0;

      while($row = mysql_fetch_array($sql))
      {     
      $result1[] = $row['thumbnail']; 
      $result2[] = $row['id']; 

      $_SESSION['thumbnail'] = $result1;



     echo $loopproduct = $result1[$loopCount1];

     echo  $loopid = $result2[$loopCount2];

     echo   " <input type='hidden' id='add' value='$loopproduct' >";
     echo  " <input type='hidden' id='csg' value='$loopid '>";


     echo"<br/>"."<br/>";              

     echo '<a  href="#" onClick="ajax_post()" >'. $_SESSION['thumbnail'][$loopCount1] .'</a>'."<br/>" ;

     $loopCount1++;
     $loopCount2++;

     }



     ?>  

0 个答案:

没有答案