www.webdeveloper.com
Results 1 to 5 of 5

Thread: multiple fields for one piece of content

  1. #1
    Join Date
    Mar 2006
    Location
    London
    Posts
    155

    multiple fields for one piece of content

    I am new to mysql, what i have now is a simple table which holds cheats,

    id game game_url console console_url cheats

    the cheats field holds mutliple cheats, what i am trying to create is 1 field = 1 cheat.

    And also adding other things like saved games.

    I can do all of the PHP, my question is how do i go about setting out and adding records to the table?

  2. #2
    Join Date
    Mar 2009
    Posts
    452
    i think you should dump your data in xml format in your field,
    ie:
    <cheat1>Some Cheat</cheat1>
    <cheat2>Some Cheat</cheat2>
    <cheat3>Some Cheat</cheat3>

    and dump it in your mysql field

  3. #3
    Join Date
    Mar 2006
    Location
    London
    Posts
    155
    thanks, would i then read this data with php ,add html etc and echo?

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,918
    I would probably try to normalize the database design, likely creating a number of separate tables.
    Code:
    game
    ===================
    ID (unsigned int, auto-increment, primary key)
    game_name
    game_url
    
    
    console
    ===================
    ID (unsigned int, auto-increment, primary key)
    console_name
    console_url
    
    
    cheat
    ===================
    ID (unsigned int, auto-increment, primary key)
    game_id
    console_id
    cheat_text
    (maybe a timestamp field?)
    This way you avoid duplication of game and cosole data, while keeping each individual cheat as a separate, atomic data row.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    thanks, would i then read this data with php ,add html etc and echo?
    I would suggest that each page that accesses or modifies your database data should perform actions in the following order:
    1. parse GET and POST variables
    2. create sanitized [and reduced] copies of [relevant] data
    3. update/insert new data, preferably using built-in functions for your DMBS
    4. select page-relevant data from the database
    5. format the retrieved data by converting necessary characters to HTML, stripping out SCRIPT tags, padding with HTML, etc.
    6. print/echo the combined HTML to the client
    Jon Wire

    thepointless.com | rounded corner generator

    I agree with Apple. Flash is just terrible.

    Use CODE tags!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles