Thread: help....

    #1
  1. chown python:users\ /world
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Texas Tech
    Posts
    95
    Rep Power
    15
    I have just started looking into MySQL..... I have used PHP for a while but never with a database....

    I know that you use mysql_create_db($databasename) to create the Database. But how do I create the tables within it?

    ------------------
    Hartmann
  2. #2
  3. No Profile Picture
    ledjon
    Guest
    Devshed Newbie (0 - 499 posts)
    Just use regular SQL, as if it was a query:
    #######
    $create_table = "CREATE TABLE asdf (field VARCHAR (34) not null )";
    $result = MYSQL_QUERY($create_table);
    #######
    That should work.
  4. #3
  5. chown python:users\ /world
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Texas Tech
    Posts
    95
    Rep Power
    15
    So that goes in my PHP statement??

    Wouldn't it be executed everytime the file runs?

  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    15
    Yes, normally you would create the tables and the databaes manually, or with something like phpMyAdmin, you can get it from www.phpwizard.net. IT is just a GUI front-end to MySQL, but it makes it much easier for those of us who don't want to learn all the syntax of SQL.

    Chris


    [This message has been edited by Chris Pickett (edited July 19, 2000).]
  8. #5
  9. No Profile Picture
    ledjon
    Guest
    Devshed Newbie (0 - 499 posts)
    >So that goes in my PHP statement??

    >Wouldn't it be executed everytime the file runs?

    Yes, it would run every time. You could put it in a conditional statement like this:
    #########
    $action = $QUERY_STRING;
    if($action == 'first_time')
    {
    $create_table = "CREATE TABLE asdf (field VARCHAR (34) not null )";
    $result = MYSQL_QUERY($create_table);
    }
    else {
    #Whatever you want down here
    }

    them if the url is entered as "page.php3?first_time" it would make the table. If it didn't have that it would do something else. Even if it said "page.php3?asdf" it still wouldn't run it again.

    I suggest making a page called first_time.php3 that makes all the tables and stuff one time and you don't have to worry about integrating it into other code.

    [Edit: Forgot a ";" in the code]

    [This message has been edited by ledjon (edited July 19, 2000).]
  10. #6
  11. chown python:users\ /world
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Texas Tech
    Posts
    95
    Rep Power
    15
    Thanks for the great help!!

IMN logo majestic logo threadwatch logo seochat tools logo