I have a SQL database where 'title' is one of the columns. I had written the function below to be passed back via AJAX to be displayed.
I'm trying to get the entire contents in title column and is stored in position 0 of the array but all I got was the first letter of the string stored in title[0] and title[1] denotes the next letter of the contents in title of the sql query. Any pointers?
e.g.
In my database the search result title[0] returns Hello World
but when I run this script title[0] returns H and title[1] returns e.
I was expecting the result of title[0] returns Hello World.
function getorders($username,$orderid)
 {
     $conn = dbConnect();
     $sql = "SELECT *  FROM `permissions` WHERE `username` = '$username' AND `orderid` = '$orderid'";
     $result=mysqli_query($conn,$sql) or die(mysqli_error($conn));
     
     if( mysqli_num_rows($result)>0 )
     {
       $row = mysqli_fetch_array($result);
         echo json_encode($row);
     }
     else{
     echo "not found";}
     
    // echo $username." ".$orderid;
 }
function myAjax() 
{
 var username = $("#username").val();
 var orderid = $("#orderid").val();
      $.ajax({
           type: "POST",
           url: 'jumper.php',
           data:{ data1:{"username": username, "orderid": orderid}},
           success:function(html) 
           { 
             const myArr = JSON.parse(html);
             document.getElementById("title").innerHTML = myArr.title[0];
           }
      });
}
 
     
    
"; } document.getElementById("title").innerHTML = titles; }` . Something like that. Adjust the exact output format to your preferences, obviously. – ADyson Aug 27 '21 at 10:04