I have an android app that pulls information from mysql db and displays it in a list. Each list item has a favorite button that upon click updates the db with the username and with the list item.
I can get all user favorites using relational and foreign key. What I am trying to achieve is when the user re-logs in to the App and scrolls for available items he can already see which items he marked as favorite without going to his favorites page.
So for example when you are scrolling in your facebook page you can already see which posts you liked.
How can I achieve that?
First table
|------------------|--------------|----|-------|
| Column | Type |Null|Default
|------------------|--------------|----|-------|
| //**id**// | int(11) | No |
| car_vendor | varchar(20) | No |
| car_model | varchar(20) | No |
| car_petro | varchar(10) | No |
| car_transmition | varchar(10) | No |
| car_hand | int(11) | No |
| car_spedometer | varchar(7) | No |
| car_engine_vol | varchar(4) | No |
| car_category | int(11) | No |
| car_post_date | date | No |
second table
|----------------|------------|----|
| Column | Type |Null| Default
|----------------|------------|----|
| //**id**// | int(11) | No |
| username | varchar(20)| No |
| favorites_id | int(11) | No | <<< foreign key points to ID on first table
Aucun commentaire:
Enregistrer un commentaire