mysql - PHP/SQL:Data from DB don't show -


i'm making form project when user insert username , click submit info show in respected area (with ajax).the problem data show column name , rest empty. have insert info needed in table, still data don't appear. below php code:

<?php require "co.php"; $link = mysqli_connect($h,$u,$p,$db);  if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } echo "connected successfully";  $q = "select * login user_name ='".$_get['name']."'"; $result = mysqli_query($link,$q); if($result){ echo "<table border='1' > <tr> <td align=center> <b>user id no</b></td> <td align=center><b>name</b></td> <td align=center><b>password</b></td> <td align=center><b>responsibility</b></td></td>";  while($data = mysql_fetch_row($result)) {    echo "<tr>"; echo "<td align=center>$data[0]</td>"; echo "<td align=center>$data[1]</td>"; echo "<td align=center>$data[2]</td>"; echo "<td align=center>$data[3]</td>"; echo "</tr>"; } echo "</table>"; }  else{ echo ' failed'; } ?> 

and include html code:

html> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>  <script type="text/javascript">  $(document).ready(function() {  $("#display").submit(function(e) {         e.preventdefault();   $.ajax({    //create ajax request load_page.php     type: "post",     url: "tesz2.php",     data: { name: $('.name').val() }, // set naem variable                  datatype: "html",   //expect html returned                     success: function(response){                         $("#responsecontainer").html(response);      //alert(response);              }             });       });    });   </script>  <body> <form method =post action=test2.php id="display"> <input type ="text" class='z' id='name'><br> <input type='submit'> </form>   <h3 align="center">manage student details</h3> <!--table border="1" align="center"> <tr>    <td> <input type="button" id="display" value="display data" /> </td> </tr> </table--> <div id="responsecontainer" align="center">  </div> </body> 

can tell me error or maybe solution. thanks

add additional javascript function displaydata() can used displaying data.

function displaydata(){   $.ajax({     url: 'tesz2.php',     type: 'post',     data:{       'perform': true,     },     success: function(data){       $('#responsecontainer').html(data);     }   }); } 

in php file have do:

if(isset($_post['perform'])==true){   //query........ } 

now add call function ajax function success.

$.ajax({    //create ajax request load_page.php   type: "post",   url: "tesz2.php",   data: { name: $('#name').val() }, // set naem variable                datatype: "html",   //expect html returned                   success: function(response){     displaydata(); //all data show                      $("#responsecontainer").html(response);             }           });     });  }); 

Comments