Youko Posted June 12, 2007 Share Posted June 12, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/55184-help-with-php-mysql/ Share on other sites More sharing options...
Crashthatch Posted June 12, 2007 Share Posted June 12, 2007 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). Quote Link to comment https://forums.phpfreaks.com/topic/55184-help-with-php-mysql/#findComment-272777 Share on other sites More sharing options...
Youko Posted June 12, 2007 Author Share Posted June 12, 2007 Thanks for the fast reply. UNfortunately the CMS software is not designed by me and I can't really change the database, since it would cause troubles and it would propably take longer for me to change how the system handles database than just make a workarround to it. Quote Link to comment https://forums.phpfreaks.com/topic/55184-help-with-php-mysql/#findComment-272779 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.