0
   Array([0] => stdClass Object([max(Transaction_id)] => 10251))

My php sql query returns the answer in this format.
How can i display the only value from this format.
Thanks in advance

Andreas
  • 23,610
  • 6
  • 30
  • 62
  • simple way you will convert stdclass to array type, after you can get data easily. for more clarity see this post . https://stackoverflow.com/questions/19495068/convert-stdclass-object-to-array-in-php – parthi Mar 23 '18 at 08:02
  • you can also get sql query result as array as well.post your code here .. – Rajeev Ranjan Mar 23 '18 at 08:32

2 Answers2

1

In your query add the as then the name of the column that you want to retreive.

SELECT MAX(COLUMNNAME) AS example example FROM TABLENAME

And then in your php file

echo $result[0]['example'];
Del
  • 164
  • 1
  • 7
  • 1
    @Obulisathish.v if its works well .you need to accept answer.if given code works for you.try to understand stackoverflow rules and docs.thanks – Rahul Mar 23 '18 at 08:57
0

if for some reasons you are unable to convert the sql query you can access to this variable in the following way

echo $obj->{"max(Transaction_id)"};
Atural
  • 5,389
  • 5
  • 18
  • 35