Hello everyone,
In this guide I am going to practically show you how to set list in ListView from a returned value of a custom MySQL query.
Citation and Credit goes to:
@Taifun - Pura Vida Apps
@Hossein - Daily Challenge 29
@Rogerio_Rios - for pointing out the mistakes.
STEP 1: Server Setup
- Put the PHP code on your web server. mysql.TXT (4.4 KB) (Please change the extension from .txt to .php before uploading)
- Set the SQLKEY in your app and in the PHP code, they must match for this code to work. Don’t use special characters.
- Setup your database connection information in the PHP script.
STEP 2: Designing the App Interface
1 Button and 1 ListView. You can use any ListView you want, I am using the default one.
1 Web component as well.
STEP 3: Preparing URL and Query to execute in the Script
This will prepare the query to execute in the php script on the provided url.
This is the table in our database.
STEP 4: Executing Query and getting values
each row of a table contains information from an “item” of the class (table).
Then the return of your Select, 4 lines were returned. The other 3 lines contain information for each item in the list. Like:
line 1, item 1 - name’s military
line 1, item 2 - rank’s military
line 1, item 3 - force’s military
next line. …
next line …
So when we receive the response we will just Split and replace the \n and , likewise:
Final look:
Final Blocks:
That’s it! You’ve got your list setup in a ListView from a custom MySQL query.
AIA File: MySQL (1).aia (6.5 KB)
Suggestions and corrections are welcomed. My next guide will be on how to make a recyclerview with MySQL Query. Thanks for reading.