Jump to content

Recommended Posts

Hello

 

I'm still learning both PHP and MySQL.

I'm in a pinch now, since I can't figure how to pull this thru.

Ok, let's get started!

 

So. I'm using this cms with a forum plugin called e107 (this inormation doesn't really matter

in this case, but if someone has experience with it, this could help)

 

Ok. I have a table named e107_user which has collum user_class.

The collum user_class has values stored as such: 1,2,3,4,5

Meaning they are separated by coma and are ascending from 1 to upwards, but not always has them

going +1 +1 +1, but can have data like 1,2,5,7.

(the table e107_user has several collums, btw)

 

Then I have a table called e107_userclass_images with collums: id and userclass_img

 

Now, what I want to do with php is it to check that if if some row in the table e107_user in the collum

user_class has an entry in it, that if the number or numbers match one or several in the

table e107_userclass_images' collum id and if it does, it saves them and outputs in php.

 

This might sound confusing, since my english terminology is not the greates.

If you have any further questions (meaning you didn't understand my babble), go ahead and ask

if you think you can help me solve this problem.

Link to comment
https://forums.phpfreaks.com/topic/55184-help-with-php-mysql/
Share on other sites

I think the root of the problem is the database design. You shouldn't be storing more than one value in a single column (oh, and it's column, not collum).

 

If you were storing each of the values currently in user_class in separate columns (or if there's an arbitrary number of them, in another table) you could use "joins" to match rows together and only return rows which have a match in both tables.

 

My advice is to read a little on Database Normalization (Wikipedia probably has a great article on it). It'll help with database design for the future, and certainly help you to solve this problem.

 

 

Note that I'm not saying there's not a way to solve it this way. There's almost certainly a method of doing what you want without creating more tables and things, it's just not the way I'd do it (And I think my way would be more elegant and faster).

Link to comment
https://forums.phpfreaks.com/topic/55184-help-with-php-mysql/#findComment-272777
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.