Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Apr 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Where Do I Place Initial php mySQL Code?

    I'm a little lost on something.

    I know I can create a database using cpanel's mySQL manager and create and edit a table with myphpadmin, but I want to learn how to program the actual code first...

    I've gone through tutorials on php mySQL, and I grasp the language, but I'm failing to read anywhere that answers my following questions...

    Where do I put the code for an SQL database and Table and its columns of data for my web site? Do I put the code in its own file and save it as .php? If so, how is the code enacted to actually create the database, table, columns, etc.? Do I include the code in my index page? Is it only supposed to load one time, since the database is created only once? I don't get this aspect of it.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Well, there's a "manual" way to do it, from a command prompt. Of course, this way pretty much sucks monkey butt, so the way I suggest is you use phpMyAdmin to create the tables as you want them, then do an "Export", structure only, and save that to a file. Now, your entire schema can be recreated in seconds-- just import that file (also using phpMyAdmin) and presto, your database is created.

    I don't know why you want to mess around with using PHP to create your database, since, as you say, this is something you'll only do once. You certainly wouldn't bother putting create table queries in your index.php file.

  • #3
    New Coder
    Join Date
    Apr 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmmm. Why does the command prompt way suck monkey butt?

    I started creating a table in myphpadmin. I didn't totally complete it, so at the bottom of the screen where there's a SAVE button next to "Or Add [number] Field(s), I pushed the SAVE button, but because all of the fields are not filled in, I can't save it. Is there a way to SAVE a partially filled out Table in myphpadmin, to come back to it later?

    This is why I want to hand-code everything. These WYSIWYG type programs always fail me. Is the command-prompt way all that hard?

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Not "hard", per se, but just more manual. I have no idea why you'd not be able to save your table-- what's the error? You can, incidentally, execute any SQL query (CREATE TABLE being just like any other SQL query) so if you want to write your CREATE TABLE statement by hand, you can still execute it through phpMyAdmin.

    You can do the same thing at the command prompt, so if you're more comfortable doing that, feel free.

  • #5
    New Coder
    Join Date
    Apr 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok. I see now where Ican click a "query" icon to pull up a box to write SQL code. I didn't see that option at first. That'll do just fine for programming area.

    But...

    After creating a table and selecting how many fields I want, a table shows with a bunch of empty fields. Now if I decide to not fill in a field or any field and press the SAVE-button at the bottom of the screen, I get an alert pop-up box that says: "Missing value in the form!" If I fill in just one value, or some values and leave blanks, I get the same message.

    Which is why I'm assuming I have to complete the whole table in order to save it, which sucks monkey butt!

    Also, when I look in the left column, where the "query" icon is, it says "No tables found in database." I'm guessing that is so because I haven't been able to save the table yet? At the top of the screen, it states the Table name though.

    P.s. I just tried something. I created one field and plugged in some values to satisfy a full column being complete. It saved. Is that normal? Should I have to complete the table one field by one field? Or have to create a whole column before it's allowed to be saved?
    Last edited by witch_wyzwurd; 04-07-2009 at 12:24 AM.

  • #6
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,313
    Thanks
    4
    Thanked 206 Times in 203 Posts
    When you create a new table using phpMyAdmin and provide it with a column count it expects you to supply all of the column details at that time. It can show you the name of the table you will be creating because you've already supplied it but it won't complete the table unless you also supply all of the column definitions for the number of columns you asked for.

    You may certainly create columns one at a time but it will likely be a bit tedious. phpMyAdmin makes the assumption that when you create a table with x number of columns you already know how you want those columns defined and expects all of the details before it will actually create the table.
    Dave .... HostMonster for all of your hosting needs

  • #7
    New Coder
    Join Date
    Apr 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok. I'm getting somewhere now. I have some more questions in mind, but I'll take these initials steps first and try to answer them myself as I plug along. Thanks.

  • #8
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi all i disliked phpMyAdmin's interface so i decided i would built a new MySQL manager like the MySQL query browser. please if you have a change can you give it a try
    github ->https://github.com/sucaritas/MyXQuery
    LIVE DEMO -> http://www.farfile.com/Demos/MyXQuery/
    it works like the MySQL query Browser (ctrl+enter to execute a query)
    you can right click on the tree for other things too.


  •  

    Posting Permissions

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