Ad Code

Ticker

6/recent/ticker-posts

QUE.COM Intelligence.

Chatbot AI, Voice AI and Employee AI. IndustryStandard.com - Become your own Boss!

Using SELECT SUBSTR - MySQL PHP

I've got to re-learn my MySQL and PHP programming skills.

I have a field name contentdata with a hex data of AA560D72DA4AB20AAA using a type char.

In MySQL, I can run this command:
SELECT SUBSTR(hex(contentdata),15,2) FROM table1
output is: 0A

How can I code "SELECT SUBSTR(hex(contentdata),15,2) FROM table1" in PHP so I can bring the same result?

MySQL create php code gave me this recommendation but I can't show the value.
$sql = "SELECT SUBSTR(hex(payload),15,2) FROM device_status LIMIT"

Let me know what I'm missing here?

UPDATE:
A member (Katherine) in domain name forum recommended to use "AS hex_value" to create aliases for the field resulting from expressions. It works!

So, I query the data using the codes below:
"SELECT SUBSTR(hex(contentdata),15,2) AS myHex_data FROM table1"


Post a Comment

1 Comments

Comments

Ad Code