Jump to content


This topic is now archived and is closed to further replies.


PHP apps

Recommended Posts

Hey guys so I am making an online App website. So I need to it to be so some apps will be added by default. Then users can search for apps and "install" apps but really just have them show up on the homepage. So how would the database design work like have a field that is updated to 1 if the user has it installed and 0 if its not. And then do like an if statement to pull all the fields with 1 where username='$username'. And when it pulls it should I add like a URL field to it to so when it pulls the app information there will be a link to the app url. Could somebody please help me with what I should do because I am really confused on what design and if statements I should use

Share this post

Link to post
Share on other sites

That sounds as a many-to-many relationship with three tables:


table 1 : users

table 2 : apps

table 3: users_apps


Table 3 is what we call a jointable which makes relations between records out of the users and the apps table.


a little example would help i guess:


users table :

- user_id (primary key, autoincrement)

- username

- password

- email

- ....


apps table:

- app_id (primary key, autoincrement)

- name

- description

- download_url

- ....


users_apps table:

- user_id (foreign key, in phpMyAdmin als index called)

- app_id (foreign key, in phpMyAdmin als index called)




some example rows in users_apps:

user_id app_id
   1       1
   1       2
   3       1

this let us know that user with id 1 have downloaded two apps: 1 and 2 

Also we see that user 3 have downloaded only one app: app nr 1.


With a little query we can also count how much times every app is downloaded: app 1 has been downloaded twice and app two has been downloaded once.






Share this post

Link to post
Share on other sites

That is not be too dificult either.


First of all your application needs to know what are standard apps and which one not. To do that you could simply add a column to the apps table with a name like for example 'default' or 'standard'.

Give apps a 1 if they are standard and otherwise a zero.


After that, when a user signed up and you store the user details into the database you can also immediately  add records to the users_apps table. (that would be a while loop with INSERT queries)

Share this post

Link to post
Share on other sites

A lot of beginners will think something like 'wow that will be a long list in the join table'.


Yes but computers are fast these days and its exactly where databases are made for. It is not a problem at all and besides of that it is the only way to keep track on which user has which apps!

Share this post

Link to post
Share on other sites

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.