Select from table

Discussion in 'PHP' started by emi87, Oct 4, 2008.

  1. #1
    Hello,
    I need a little help with connecting two tables. I think!!
    I want to create a mysql table in this form if it is possible:
    table name Cars with fields Name, Year, Color, Options(where i want to insert how many options I want) ..it will look like this

    Cars - name
    - year
    - options -> airbag, full electric, etc.
    - color

    I need
    - the code to create such a table...or 2 tables and how to connect the 2 tables...
    - and how to output all options from the options field
    I have posted this in database section but no answer :(
    Please help!
    Sorry for my bad english
    Thank you very much!
     
    emi87, Oct 4, 2008 IP
  2. SeanBlue

    SeanBlue Peon

    Messages:
    110
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I would suggest giving this a look http://www.tizag.com/mysqlTutorial/mysqltables.php and learning the basics. Alternatively you could try installing phpmyadmin which is a graphical browser interface for MySQL and is great if you're just starting out.

    I think you would want something like this, dependent upon what you're doing with the table. For the 'options' field you could either store them as coma separated values like 'airbag,full electric,hi-fi' and use PHP to decode and display, or you could simply create a new field in MySQL for each one and have a yes or no (probably a better way of doing it).

    CREATE TABLE `mcdonalds`.`Cars` (
    `name` VARCHAR( 250 ) NOT NULL ,
    `year` SMALLINT( 4 ) NOT NULL ,
    `options` VARCHAR( 250 ) NOT NULL ,
    `color` VARCHAR( 250 ) NOT NULL
    );
     
    SeanBlue, Oct 4, 2008 IP
  3. techcone

    techcone Banned

    Messages:
    206
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try XAMPP server.

    With Apache , PHP and Mysql all in one.
     
    techcone, Oct 4, 2008 IP