0

Hi. this us what Im doing and its not working:

test.php

$(rclone).on("click", function(){
    var event_id = $("#event").val();
    var euser_id = $("#userid").val();

    $.ajax({
      type: "POST",
      url: "InputNames.php",
      data: "event_id="+event_id+"&euser_id="+euser_id,
      success: function(data){
          var form = $("#input-names").html();
          $(".form-inputs").html(form);
      }
    });
});

InputName.php:

<?php
    $id = $_POST['event_id'];
    $userid = $_POST['euser_id'];

    require "connection.php";

    $get = $dbh->prepare("SELECT guser_id,guest_id,guest_name,event_id,status FROM guest1 WHERE event_id = ? AND guser_id = ?");
    $get->bindParam(1, $id, PDO::PARAM_INT);
    $get->bindParam(2, $userid, PDO::PARAM_INT);
    $get->execute();

    if($get->rowCount() > 0)
    {
        $get->setFetchMode(PDO::FETCH_ASSOC);
        while($row = $get->fetch())
        {
            $guest_id = $row['guest_id'];
            $guest_name = $row['guest_name'];

            echo "<div class='form-inputs'>
                    <div class='insertnames'>
                        Table Name : <input type='text' id='table_name' required><br><br>    
                        Name 1 : <input type='text' class='textbox' id='name1' value=''><br> 
                        Name 2 : <input type='text' class='textbox' id='name2' value=''><br>
                        Name 3 : <input type='text' class='textbox' id='name3' value=''><br>
                        Name 4 : <input type='text' class='textbox' id='name4' value=''><br>
                        Name 5 : <input type='text' class='textbox' id='name5' value=''><br>
                        Name 6 : <input type='text' class='textbox' id='name6' value=''><br><br>
                        <input type='button' id='submit' value='Submit'/>
                        <input type='button' id='cancel' value='Cancel'><br>
                    </div>
                </div>";
        }
    }
?>

checked the console , f12, event_id and euser_id are sent. .input-names is a div in test.php where .form-inputs is suppose to be displayed in but nothing happens, data gets sent but no response. please help. thanks in advance

2
Contributors
4
Replies
16
Views
2 Years
Discussion Span
Last Post by nadiam
0

There is no echo if you do not have results. Send something if row count is zero, so you can check that that maybe the case. You won't get anything back either if your code crashes, so I suggest adding a try..catch.

0

found the problem. it was my query, wrong info. but it still does not display the results on the page. although in the console preview and response shows the result. how do i display the results?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.