title: Load Data from db, Post it with AJAX to update db, Return back to Load new data! Completely Confused
body: <p><em>I want to get my data from mysql db with php and assign them to my javascript array. I have 200 records in my db and i will get 10 records randomly.</em></p>
  
  <pre><code>$myQuery = mysql_query("select * from tblx where xyz=1 order by rand() limit 10");
  </code></pre>
  
  <p>*What i want to do is take these records to assign them in to an array than show them into my page one by one with fade effect or something else. The user is clicking one of them and its posting the value of this to db than it has to execute a callback function to load new data.</p>
  
  <h1># # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #</h1>
  
  <pre><code>                              EDIT 2013.06.11
  </code></pre>
  
  <h1># # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #</h1>
  
  <p>I'm completely confused so please let the logic clearer.</p>
  
  <p>Here where i get my data from db.</p>
  
  <pre><code>index.php
  
  
  $sorular_hepsi = mysql_query("select * from tblsorular where hafta=1 order by rand() limit 2");
      $soru_ust = mysql_fetch_assoc($sorular_hepsi);
          $soru_id = $soru_ust_rs["id"];
          $soru_grup_id = $soru_ust["sId"];
  
  $soru1 = $soru_ust["soru"];
  
  $sorular = mysql_query("select * from tblsorular where sId=$soru_grup_id");
  $totalKayit = mysql_num_rows($sorular_rs);
  
      while ( $sorular_rs=mysql_fetch_assoc($sorular)) {
          $sorular2[] = $sorular_rs["soru"];
          $sorular2Id[] = $sorular_rs["id"];
      }
  
  $userId = 1234;
  </code></pre>
  
  <p>And here is the listed objects in <code>index.php</code></p>
  
  <pre><code>&lt;div id="sorugonder" class="soruStyle"&gt;
          &lt;a href="#" class="sorugonder" id="&lt;?=$sorular2Id[0]?&gt;"&gt;&lt;?=$sorular2[0]?&gt;&lt;/a&gt;
      &lt;/div&gt;
  
      &lt;div id="soru_sag" class="soruStyle"&gt;
          &lt;a href="#" class="sorugonder2" id="&lt;?=$sorular2Id[1]?&gt;"&gt;&lt;?=$sorular2[1]?&gt;&lt;/a&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>And here is my ajax function to send my data to <code>islem.php</code></p>
  
  <pre><code>$(function() {
      $(".sorugonder").click(function() {
      // $('#load').fadeIn();
      var commentContainer = $(this).parent();
  
      var id = $(this).attr("id");
      var string = 'id='+ id ;
  
      $.ajax({
         type: "POST",
         url: "islem.php?islem=soruKayit",
         data: string,
         cache: false,
  
         success: function(data){
  
         commentContainer.slideUp('slow', function() {$(this).remove();});
               $('#sorugonder').fadeOut(1000);
               $('#soru_sag').fadeOut(2000);
  
               console.log(string);
               // alert(id);
              }
          });
  
          return false;
  
      });
  });
  </code></pre>
  
  <p>This function printing console log as <code>id=xx</code></p>
  
  <p>And here is my islem.php page to get ajax data</p>
  
  <pre><code>if(isset($_POST["islem"]) &amp;&amp; $_POST["islem"]=="soruKayit"){
  
      header('Content-type: application/json');
  
      $id= $_POST['string'];
      $cevapTarihi = date("d-m-Y H:i:s");
  
      $cevapId = json_encode($id);
      $userId = 1234;
  
       $kayit = @mysql_query("INSERT INTO tblk_skor VALUES(NULL, $userId,$cevapId,$cevapTarihi)");
  
          if(!$kayit){
                  echo "Error:".mysql_error();
          }
  
      die();
  
  }
  </code></pre>
  
  <p>I've 4 different png pictures and i'm using them as a background for them. For example :</p>
  
  <pre><code>$1 = '&lt;img src="../img/1.png" /&gt;';
  $2 = '&lt;img src="../img/2.png" /&gt;';
  $3 = '&lt;img src="../img/3.png" /&gt;';
  $4 = '&lt;img src="../img/4.png" /&gt;';
  </code></pre>
  
  <p>I have change my listed datas background on each post process. But i couldn't figure it out how and where i have to put them?</p>
  
  <p>$.ajax function doesn't send my data to islem.php or i can't get it. </p>
  
  <p>Simply : </p>
  
  <ol>
  <li>I want to add my record to database (just id )</li>
  <li>I have to execute callback function to repeat this process 10 times with 10 different records.</li>
  <li>After finish this 10rec i'm going to calculate the results and redirect to another page.</li>
  <li>Changing backgrounds every post step.</li>
  <li>Countdown! I have to put countdown into a div to users click it in 10 seconds. Otherwise i have to execute another error function to start all this again. I couldn't find a proper countdown script to demonstrate on my functions.</li>
  </ol>
  
  <p>Just this.</p>
  
  <p>Any suggestions?</p>