SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    May 2001
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ENUM types, MySQL, and PHP/web-based Content Management Systems

    Hi Folks,

    I have a question about entering values for ENUM columns with an entry into a MySQL database via a web-based PHP content management system...hope I make sense so far. I posted a few times about ENUMs before on the site, and a few people were very helpful in directing me to a few scripts on PHP.net that do things like that which I describe above...however, that being said I would like to write scripts based on my existing knowledge about ENUM type storage in MySQL databases, and writing PHP scripts, which is very little, but I'm working on it! : Anyway, the main reason that I am approaching it this way is because I will be essentially the sole administrator over the site I am designing, and thus I would like to have as much of an understanding as possible about as many aspects of it as I can in order to be able to troubleshoot effectively.
    Here we go...from what I understand about MySQL and how it stores and works with ENUM type columns and values, if someone had a set # of values that they wanted to store in a MySQL database, then an ENUM type column would be a good choice. I will offer an example of one of the things I am trying to do, although I will simplify it slightly in order to hopefully better explain it.
    Say that one had 100 countries that they wanted to enter into the database. If they created a table in MySQL of type ENUM, and entered the values as "Canada, United States, Australia..., Africa, etc.", after they were entered into the database MySQL would "think" of them in terms of numbers...i.e. - "1, 2, 3,..., 75, etc.". Please correct me if I am wrong though! Anyway, what I was thinking, was that since PHP automatically assigns the values entered in a form field in an HTML page to a variable, then if these values matched those that MySQL recognizes as numbers between 1-100 (in the countries ENUM column) then perhaps they would be speaking the same language. I hope I am headed in the right direction with this. This is something like how I envisioned the values being written into an HTML page form:

    <SELECT NAME="country">
    <OPTION VALUE="1">Canada</OPTION>
    <OPTION VALUE="2">United States</OPTION>
    <OPTION VALUE="3">Australia</OPTION>
    ...
    <OPTION VALUE="75">Africa</OPTION>
    etc. </SELECT>

    Am I thinking correctly about this? I hope I am not hideously off on a tangent, 'cause if I don't get this figured out soon, my boss is gonna fire my a$$! heh heh
    I am almost to the chapter on Arrays in my PHP book, as well as the chapter on interacting with SQL databases, but it is gonna take me at least a few days if not a week or so to read it all, and I really need to get this stuff done! If anyone would be able to at least tell me if I am thinking along the right lines, it would be great...and if someone were to even help me along a bit, that would be super!

    Cheers,

    XGuy.

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just make it an INT(3).

  3. #3
    SitePoint Zealot
    Join Date
    May 2001
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    re: Anarchos

    Make what an INT(3)? The country column in the MySQL database? Then I wouldn't have any record of what countries were which without looking up my web page scripts...I would rather have something descriptive in both places...hope I didn't misinterpret you!

    -XGuy.


Bookmarks

Posting Permissions

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