#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    3
    Rep Power
    0
    Hello,
    my database table has a column "Colour". There you can find different linguistic versions (english, french, german) of the same colour.

    Example: red (german: rot; french: rouge)

    How do I have to write my query string in MYSQL/PHP in order to get the three versions when asking for "red"?

    I have tried the following:

    -----------------------------------------
    if ($colour == "") {$colour = '%';}
    if ($colour == "red") {$colour2 = "rot";}
    if ($colour == "red") {$colour3 = "rouge";}

    $sql = "select * from table where (colour like '$colour' or colour like '$colour2' or colour like '$colour3')";
    -------------------------------------------

    I always get the answer " No data found..", but there is some data that should be found.

    Please, tell me how to modify this coding to get it run correctly.

    Thank you
    Niko
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Location
    Netherlands
    Posts
    77
    Rep Power
    15
    You can make two tables: colours and languages. In the first you put all the colornames for each color and language. In the second you define the languages.

    Table Colors
    colorID/LangID/ColorName (Primary ColorID, LangID)
    1 1 Red
    1 2 Rood
    1 3 Rot
    1 4 Rouge
    2 1 Blue
    2 2 Blauw
    etc.

    Table Languages
    LangID/Language (Primary: LangID)
    1 English
    2 Dutch
    3 German
    4 French
    etc.

    Now to get all the language names for Red (colorID=1):
    select ColorName from Colors where ColorID=1;

    Or you make one table with different language fields, and a row for each color:
    ColorID/EnglishName/DutchName etc.
    1 Red Rood ...

    Then select the row you want:
    Select * from tablename where ColorID=1 (or where EnglishName='Red');

    Just try what suits your needs best.

    Peter

  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    3
    Rep Power
    0
    Hi Peter,

    Thank you so much for your help!

    Regards
    NiKo

Similar Threads

  1. Invalid characters with PHP and MySQL
    By gio50000 in forum MySQL Help
    Replies: 2
    Last Post: November 18th, 2004, 08:59 AM
  2. Replies: 2
    Last Post: October 22nd, 2003, 09:07 PM
  3. Errcode:13 . How to solve it on MySQL + Windows 2000
    By hankycheng in forum MySQL Help
    Replies: 28
    Last Post: August 3rd, 2003, 10:05 AM
  4. Cronjob madness
    By eliteboo in forum Linux Help
    Replies: 10
    Last Post: July 14th, 2003, 10:49 AM
  5. PHP variables from MySQL -> Flash
    By Tbone in forum Flash Help
    Replies: 9
    Last Post: March 22nd, 2003, 07:40 PM

IMN logo majestic logo threadwatch logo seochat tools logo