mysql table creation using phpmyadmin

Discussion in 'Programming' started by Colbyt, Feb 1, 2008.

  1. #1
    I am wanting to add a table to a database and have never done it before. I made these entries and then made the screen shot without saving.

    I want 3 fields in the table:
    A unique id number that auto-increments where the first entry will be assigned number 1,
    A text field (category) limited to 30 alpha characters and
    A method to define whether the category name is active or not.

    Here is a link to the phpmyadmin screenshot.

    I would prefer when pulling the list of categories from the database that they be in alpha (a-z) order. Not sure if I do that with the index function or the php when I pull the query.
     
    Colbyt, Feb 1, 2008 IP
  2. jorgy

    jorgy Peon

    Messages:
    611
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The unique ID will automatically be assigned 1 for the first value. As far as the method to define whether the category name is active or not, I'd recommend a value that is 0 automatically, indicating an inactive category. Then write some code using PHP to access the database that will change the value to 1 when the category is active.

    As far as ordering them, you would do that with a PHP function when you pull the query. It would look something like:

    $pull = mysql_query("SELECT * FROM (databasename) ORDER BY category ASC");
    $fetch = mysql_fetch_array($pull);
     
    jorgy, Feb 1, 2008 IP