Jump to content

[SOLVED] Displaying block of text from mySQL database


a_bains

Recommended Posts

Hello,

 

I would like to create a details.php page that displays all my products. I understand how to get the title, price, description etc from mySQL. But my problem is how do I get a list of data? For example say I want to display the features of a product in point form (list). What is the best way to do this? How do most common websites do this?

 

OK, sorry if I am unclear.

Here is an example http://www.simplyfta.com/indvitem.php?item_id=10

 

That site uses PHP and mySQL, it has sections for SPECS and FEATURES. Description is easy you would just use the fetch array function and print it out. But if I want display my data as a list, how would i do that. I am supposing that SPECS and FEATURES are data in an mySQL table row. How do they input that data into mySQL table row to display it on a page using PHP in a list format. I really just want to know the method they used to display a point form list, may also look like its in a table format from a mysql database.

 

Thanks, in advance

 

Aaron

Correct, therefore what would be the best way to store something like that? I am looking to have a list of feature/specs for my products and would like to store them in a mySQL database. I was thinking of having ONE table with all products with fields like (ID, NAME, PRICE, ... ), should SPECS be another field? If so, how would I print it out in a list format?

If  your product line is 1 product, wooly jumpers, say, and the spec items are color and size then you might just need

[pre]

product

----------

id

description

color

size

[/pre]

But if you are selling electrical items, say microwaves and washing machines, then the items in each group have different sets of specifications so things get a little more complicated

 

[pre]

category            product              prod_spec          spec_item

----------          -------------        -----------        -----------

cat_id  <----+      prod_id    <------- prod_id     

category      |      description          spec_id  ------->  spec_id

              |      make                value              spec_descrip

              |      model                              +-- cat_id 

              +----- cat_id                              |

              |                                          |

              +------------------------------------------+

[/pre]             

So spec items for microwaves might be "wattage, capacity, grill" and for washing machine "spin speed, max load, program settings".

 

On the other hand, you might just opt to put the spec in a text field for each product and type out the specification which is simpler but can lead to inconsistencies  eg

 

[pre]

Watage : 800W              (deliberate mispelling to illustrate potential problem)

Capacity: 11 litres

Grill : 1000W

[/pre]

Archived

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

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