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

2
  • simple way you will convert stdclass to array type, after you can get data easily. for more clarity see this post . stackoverflow.com/questions/19495068/… Commented Mar 23, 2018 at 8:02
  • you can also get sql query result as array as well.post your code here .. Commented Mar 23, 2018 at 8:32

2 Answers 2

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'];
Sign up to request clarification or add additional context in comments.

1 Comment

@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
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)"};

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.