php - How to perform ajax post request to get some values from the last row of? -




hi asked data last row in database using ajax post request. have 2 files php scrip used connect database , data , convert data json format. performed ajax post php script data. want modify ajax post request additional data last row of tables in database.

for example, in student table, there 10 rows of data in database. want data last row. question how values last row in database.. requirement: not modify sql code need data , additionally last row of data. not want code data[9]['student_name'];

here code below... html file

<html> <head> <script type="text/javascript" src="/cesium-1.34/thirdparty/jquery-1.11.3.min.js"></script>  </head> <div id="result"</div> <script type="text/javascript"> showdata(); function showdata() {     $.ajax({         type: "post",         url: "student.php",         datatype: "json",         data: "how request data last row of database????         success: function(data){             console.log(data);         }     }); };  </script> </body> </html> 

php script

<?php  $conn = mysqli_connect('localhost','root','netwitness') or die ("could not connect database"); $db = mysqli_select_db($conn,'abdpractice') or die ('could not select database');  $result = mysqli_query($conn,"select * student"); $json_array = array(); while ($row = mysqli_fetch_assoc($result)) {     $json_array[] = $row; }  echo json_encode($json_array); ?> 

my question how data last row of database?

requirement: not modify sql code want modify ajax post. please me. project.

change php code follows.

<?php  $conn = mysqli_connect('localhost','root','netwitness') or die ("could not connect database"); $db = mysqli_select_db($conn,'abdpractice') or die ('could not select database');  $result = mysqli_query($conn,"select * student"); $json_array = array(); while ($row = mysqli_fetch_assoc($result)) {     $json_array[] = $row; } $limit = count($json_array); echo json_encode($json_array[$limit-1]); ?> 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -