How to display the file from mysql database into Ionic App

Hi , im new to Ionic , i creating a project which will display a file like docx, ppt. jpg. or txt. file , my server is php .
1st ive created File upload in php and it will save it in my database , the problem is , i dont know how to display the file that i uploaded from php server into my Ionic app , i search a lot of things on online but i can get any tutorial about this. can somebody help me about my problem ? I am doing this for a months .

use API ( observable , rxjs ) to get the data from the php file then save it in array and display !! plain simple

Hi , thanks for quick reply , can you show me a sample of code ?
because i don’t know how to create my own api about displaying file from php into my Ionic app . that’s my another problem . and Thanks for the help…

This is a sample code which encodes all the rows in json format

$result = mysql_query($query);

$rows = array();

//retrieve and print every record
while($r = mysql_fetch_assoc($result)){
    // $rows[] = $r; has the same effect, without the superfluous data attribute
    $rows[] = array('data' => $r);
}

// now all the rows have been fetched, it can be encoded
echo json_encode($rows);

where can i make it that code ?
do you have a sample or know project about this ?

Here’s some videos can help you


Ionic 2 fetch data from Restful API

I follow the tutorial and i get this error

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\restore\read.php on line 21
"0 result"

My table name is id , files , title and description

how to fix this ?

Hi guys , I already made it , it took me a days before i solve my problem…
Thanks for the help and for giving me a great tutorial… i will now close this topic, and again Thank you ! :slight_smile: