00falcon Posted December 5, 2007 Share Posted December 5, 2007 Hi All... I don't even know if im on the right track... But... I just recently learned how to Insert, Update, Delete and Display basic data being pulled from a mysql Database... What i want to do now is have one field named "compatible models" and inserted into that would be something like: 310-4482 312-0191 312-0309 315-0084 D510/D610 U1544 W1605 0X217 1X793 310-4482 310-5195 312-0068 312-0191 312-0309 315-0084 Now... is it possible to get php/mysql to seperate the data each time it comes across a space...? I want to list the "Laptop Battery" and all of its relevant spec... and underneath that... i want to neatly display a list of the "Compatible models" As i said... im not even sure if im on the right track... if someone could point me in the right direction.... am sure i could find a tutorial from there Thanks Quote Link to comment https://forums.phpfreaks.com/topic/80224-help-with-seperating-data-within-mysql-fields/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 5, 2007 Share Posted December 5, 2007 Putting multiple values into one field like that is not the proper way to design a database application. As you have found, putting the data in and retrieving it is about 5x more difficult than it needs to be. What you should be doing is adding a separate row for each compatible model number for any battery id number. battery_id compatible_model 1 --------- 310-4482 1 --------- 312-0191 ... To retrieve all the information for that battery id number, you just query for rows that match (which for your example would give you 15 rows.) You would simply loop through all the rows using php and output them the way you want. Quote Link to comment https://forums.phpfreaks.com/topic/80224-help-with-seperating-data-within-mysql-fields/#findComment-406641 Share on other sites More sharing options...
roopurt18 Posted December 5, 2007 Share Posted December 5, 2007 PFM is describing the process called normalization. You may want to google it. Quote Link to comment https://forums.phpfreaks.com/topic/80224-help-with-seperating-data-within-mysql-fields/#findComment-406667 Share on other sites More sharing options...
00falcon Posted December 5, 2007 Author Share Posted December 5, 2007 Hi... Thanks for the reply... excuse my ignorance.... but i don't quite under stand... What i was thinking was... I have about 12 differant brand (ie. acer, sony, ibm, toshiba, etc) incorporating about 60 -70 different batteries... with those 60 - 70 different batteries suitable for over 200 different model types... My assumed DB structure was something like id date_in out (being out of stock) make model oem_number compatible_number battery_spec (probably would be more than one field) internal_code price What i am trying to achive is something like: http://www.laptopbattery.co.nz/products.asp?product_no=17424 with the "Compatible Model Numbers" down the bottom Thanks in advance for any help... Quote Link to comment https://forums.phpfreaks.com/topic/80224-help-with-seperating-data-within-mysql-fields/#findComment-407149 Share on other sites More sharing options...
roopurt18 Posted December 5, 2007 Share Posted December 5, 2007 Did you bother doing any research into what normalization is? Quote Link to comment https://forums.phpfreaks.com/topic/80224-help-with-seperating-data-within-mysql-fields/#findComment-407157 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.