Help with querying MySQL database

results is the ID for the box element that I want the data to display in.

When I press the button on the live website, on console it shows that the data is being pulled from test.php but is just not showing in the ‘results’ box on the hype page.

So the function is working and its getting the information that’s needed. I just need it to be displayed on the live webpage :grimacing:

No warnings are showing up in the console either. Its just not displaying the information obtained from test.php within the hype element with the ID ‘results’

I would first try a simple button where you run the code to insert a simple string into the results field and verify that is working as expecting. It sounds like there is a disconnect in inserting it if indeed the success function is being triggered with the correct “res” data.

1 Like

my code is similar to the one found on this feed:

However, they have managed to actually get the information to display within the hype document. I can’t really see what I’m doing wrong / different here. I just get a blank box where the data should be displayed no matter what I try.

Here’s my files so far. I’ve changed them a bit and tried a few things with still no results. I think it’s something really simple that I’m missing but I just can’t work it out. Getting data from a database to display in hype is a lot harder than I expected especially as sending data to the database was pretty simple.

data recieve from (41.5 KB)

If anyone has any solutions then I’ll be really grateful.



The zip doesn’t seem to extract for me; can you try again/a different method?

1 Like

Hi @Jonathan

I’ve loaded both files onto drop box and created 2 share links:

The PHP file:

The HYPE file:

Hope this works and thanks again,


hi! i got success with this php and hype in (104,1 KB)

1 Like

hi @strmiska

have you created that on hype 4.0? I’m unable to open it on 3.6.7 as it’s saying it was created in a newer version.



sorry, ialways forget, that documents aere autosaved in newest versions. (104,5 KB)

1 Like

Thanks for this! I’ll have a play around with it to see if I can get this working on my server and then attempt to use the code for my project :slight_smile:

1 Like

great! i use it for creating a score- list automatically after finishing a game.
it´s working really cool.

1 Like


When sending an Ajax request as dataType: JSON you’ll have to return (or echo out) the response as JSON as well so in your PHP file you should be using json_encode($variable) that way your AJAX success property (function) will contain the echo’d content.

There are inherent problems in my opinion though as you’re echoing out HTML too and aren’t really dealing with arrays / objects of information so JSON may not be the best in this case. Maybe look into using the dataType: HTML with AJAX.

1 Like

I’m planing to use it to inform people of the last used site on the body where insulin was administered to make sure they choose a different site the next time. This is why I need data from a data base to be displayed. I’ve already created a system to send the information to the database so this should help complete the next steps of the idea development. Long way to go though!

Thanks @DBear I’ll look further into this :slight_smile:

Hi @strmiska

I’ve managed to get your example working perfectly. I was just wondering if you had managed to get more than one row of data to be received from the database to display in hype?

for example using the PHP:

$sql="SELECT * FROM $tableName WHERE id = 3 AND id = 2";

isn´t it possible using this?

$sql = "SELECT * FROM $tableName";

then you have to create a table in innerHTML of an rectangle to display the whole sql
EDIT: if you want specifical rows only - this example i never tried, sorry.
for this i´ve to test, but haven´t time yet

Ideally I need to each part of the data to be in its own innerHTML so I can use it in hype to trigger other javascript events

that´s tricky, but for this i´m not the right person. i´ve to make tests, but time is missing at this moment

No problem and thanks for your help. I’m currently exploring if MySQL can send only the data that I need as well but I’m not sure how it all works just yet.

1 Like

@DBear is genius in this - he helped me out a lot :sunglasses:
maby he can help you , too