Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php jqueryajax Post,将它们添加到DB中,返回数据并再次重复该过程_Php_Mysql_Jquery_Post - Fatal编程技术网

Php jqueryajax Post,将它们添加到DB中,返回数据并再次重复该过程

Php jqueryajax Post,将它们添加到DB中,返回数据并再次重复该过程,php,mysql,jquery,post,Php,Mysql,Jquery,Post,我完全糊涂了,所以请让我把逻辑解释清楚 这里是我从数据库获取数据的地方 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_i

我完全糊涂了,所以请让我把逻辑解释清楚

这里是我从数据库获取数据的地方

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;
下面是
index.php

    <div id="sorugonder" class="soruStyle">
        <a href="#" class="sorugonder" id="<?=$sorular2Id[0]?>"><?=$sorular2[0]?></a>
    </div>

    <div id="soru_sag" class="soruStyle">
        <a href="#" class="sorugonder2" id="<?=$sorular2Id[1]?>"><?=$sorular2[1]?></a>
    </div>
$(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;

    });
});
此功能将控制台日志打印为
id=xx

这是我的islem.php页面,用于获取ajax数据

if(isset($_POST["islem"]) && $_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();

   }
我有4张不同的png图片,我用它们作为背景。例如:

$1 = '<img src="../img/1.png" />';
$2 = '<img src="../img/2.png" />';
$3 = '<img src="../img/3.png" />';
$4 = '<img src="../img/4.png" />';
$1='';
$2 = '';
$3 = '';
$4 = '';
我已经在每个后期处理中更改了我列出的数据背景。但我不知道该怎么放,放在哪里

$.ajax函数不会将数据发送到islem.php,否则无法获取数据

简单地说:

  • 我想将我的记录添加到数据库(仅id)
  • 我必须执行回调函数,用10条不同的记录重复这个过程10次
  • 完成这个10rec后,我将计算结果并重定向到另一个页面
  • 每一步都要改变背景
  • 倒计时!我必须将倒计时设置为div,以便用户在10秒内单击它。否则,我必须执行另一个错误函数来再次启动所有这一切。我找不到合适的倒计时脚本来演示我的函数
  • 就这个


    有什么建议吗?

    ajax中的
    data
    选项应该包含要发送到服务器的数据

    $.ajax({
       type: "POST",
       url: "islem.php",
       data: [{ name:'islem', value:'soruKayit' },
              { name:'id', value:id }],
       cache: false,
       ....