Help with querying MySQL database

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

Regards Chris
Your query has been very educational, I am starting in Hype, thanks to your question I have been able to visualize Mysql data.
You have commented that you have sent information to the database, it would be possible for you to share it with me on file to learn from your experience.

I appreciate your support on the matter. :grinning:

Hi Idiaz,

Thanks for your message.

I have these code snippets you can use that I edit every time I want to achieve sending information to mysql. I sure someone on here will be able to improve but it's a starting point for you.

The information I send to my database in this example is date, time, record, size and resultsend. Your mySQL database must match the data you're sending to it so change these parts as needed.

First place this code in a a function on hype:

// element - DOMHTMLElement that triggered this function being called
// event - event that triggered this function being called
function resultsend(hypeDocument, element, event) {
    url: 'resultsend.php',
    type: 'POST',
    dataType: 'JSON',
    data: {
          date: $('#date').text(),
          time: $('#time').text(),
          record: $('#record').text(),
          size: $('#size').text(),
          resultsend: $('#resultsend').text(),
// I never managed to get the success function to work. Maybe someone reading this could improve on this part?
   success: function (res) {


// I go to another scene on my project once data has been attempted to be sent. Delete if not needed. (if you manage to get the success function to work you may be able to change something on the scene to show its successfully sent).
hypeDocument.showNextScene(hypeDocument.kSceneTransitionInstant, 1.1);
} else {

// I use a scene to test my internet connection. Delete if not needed. This was only included as I couldn't get the success function to work. 

hypeDocument.showSceneNamed('connection', hypeDocument.kSceneTransitionInstant, 1.1)


Then create a .php file called resultsend.php and include the following


     // get values form input text and number

$date = $_POST['date'];
$time = $_POST['time'];
$record = $_POST['record'];
$size = $_POST['size'];
$resultsend = $_POST['resultsend'];

    // connect to mysql database using mysqli

$connect = mysqli_connect($hostname, $username, $password, $databaseName);
    // mysql query to insert data

$query = "INSERT INTO `$resultsend`(`date`, `time`, `record`, `size`) VALUES ('$date','$time','$record','$size')";

$result = mysqli_query($connect,$query);


You should have a config.php which includes your mySQL database hostname, username, password and database name.

If anyone can improve on this method please contribute. I'm sure there more secure ways to do all of this.

Let me know how you get on,


1 Like

5 posts were merged into an existing topic: Save Data PHP MySQL