Jump to content

Help with seperating data within MYSQL Fields???


Recommended Posts

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

 

 

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.

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

 

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.