SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    Former Staff Member silver trophy Adam P.'s Avatar
    Join Date
    Apr 2001
    Location
    San Francisco
    Posts
    3,288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What are some ways I would set this up?

    I asked this question almost a month ago in the "Web Design" forum and got some good answers relating to PHP and MySQL. Therefore I began learning it and am about half way through Kevin Yanks' tutorial on building a database. Here's my question:

    I recently finished my site www.help4newbies.com . I don't have a great deal of content right now, so organization and updating isn't hard. But I'm worried about when my site starts to get content heavy in the very near future (maybe a couple weeks from now).

    I have 5 sections of tutorials: HTML, CSS, JavaScript, PHP, and Misc. Right now I have it so that when you go to the section, you see the contents of that section listed at the top. Each is a link to the tutorial on that same page.

    My problem is going to be when I start getting a lot of tutorials. I obviously don't want all of the tutorials on one page, when there get to be a lot, b/c of loading time. So I was thinking and came up with the idea of having a maximum of 4 tutorials per page. Then I'd just keep adding pages to each section with a "BACK" and "NEXT" link on each page.

    Now comes another problem. I have the tutorials in alphabetical order. So if I need to add one thats name goes somewhere in the middle, than I would have to shift all of them from page to page. Also, stuff like a site map, author/submit signatures, etc. are time consuming to update. How should I use PHP and MySQL to work this out with a database.

    That was pretty much my question. Feel free to answer to the question above, but after learning quite a bit, I've got some more questions:

    1. Right now I use CSS to format my text (font size, color, family, etc.). Where will I put "class=" or "sytle=" if I use a database? Does it go in the echo, or what?

    2. I have a horizontal line between each tutorial. Is there a simple way I can do that while using a database?

    3. If I'm using a database for the tutorials, should I also use it for pages like "About Us" or "FAQs" which don't get daily, or even weekly updates, usually? Or would it just be easier to use HTML on that page?

    Of course more questions are going to arise, I'll post 'em here. I'd appreciate if you check back once in a while Anyways, that's it for now. Help me out! Thanks
    SPF Mentor/Advisor 2001-2003
    SPF Designer of the Year 2002
    SPF Graphic Designer of the Year 2003
    AdamPolselli.com

  2. #2
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello again swimm!

    Being familiar with your site, and knowing the great potential it has, there is no alternative but to database it, and you are best to do it now, rather than create a lot of work for you in the future.

    Its hard to tell from your code at the moment, but in case you are not doing it, I would first template the site. That way you can rip out all the standard bits, which means inserting the articles is infinitely easier.

    About the database. Well this is where the templates come in -- all the text is simply retrieved from the database, entered into a template, and formatted accordingly. You might consider something like php-nuke which basically does what you want already (and more!) or design your own (a good solution if you want to get really good).

    Anything else?
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  3. #3
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree, first make a template of the site, so that if you want to make a change to the layout you only have to do it once in the template You can store all of your CSS in your template.

    Then you can start thinking about what you are going to need to store in the database and how you are going to structure the db.

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  4. #4
    1-800-JMULDER JMulder's Avatar
    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    1,745
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey swimm5001

    Heh, I can answer your Previous/Next question

    Ok, let's say you have this URL http://www.help4newbies.com/tutorials.php?page=0

    First you need to tell PHP there's a $page variable:

    PHP Code:
    <?php

    settype
    ($page,"integer");
    $startpoint $page 4;
    $startpointNext $startpoint 4;
    Ok, you now set the $page variable and told the string can only be a number.
    Then I defined the starting point --to use in the MySQL query-- where the page should start, and I defined where the Next page should start.

    Then the MySQL query:

    PHP Code:
    $TutList mysql_query("SELECT * FROM Tutorials order by TutID DSC LIMIT $startpoint,4");
    $TutListNext mysql_query("SELECT * FROM Tutorials order by TutID DSC LIMIT $startpointNext,4");
    $totalNext mysql_num_rows($TutListNext); 
    That should explain itself I hope
    $totalNext is used to check if there is a next page.

    PHP Code:
    Query for displaying the tutorials here using a WHILE-function 
    Now the Previous and Next links:

    PHP Code:
    <?
    if ($page 0) {
    ?>

    <a href="<? print $PHP_SELF ?>?page=<? print $page-1 ?>">Previous Page</a>

    <? }
    if ((
    $page 0) && ($totalNext 0)) print " - ";
    if (
    $totalNext 0) {
    ?>
                      <a href="<? print $PHP_SELF ?>?page=<? print $page+1 ?>">Next Page</a>
    <? ?>
    Phew, hope that works, had to write this fast. Ofcourse you can sqeeuze variables in like the category and such.
    Jeroen Mulder

    w: www.jeroenmulder.com

  5. #5
    Former Staff Member silver trophy Adam P.'s Avatar
    Join Date
    Apr 2001
    Location
    San Francisco
    Posts
    3,288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    weirdbeard and sean: You said to template my page. I think it already is, I'm just not completely sure what it means. I used PHP INLCUDEs for the top banner, side nav., content, and copyright. It's been like that for a while. Then I just change the content in an individual HTML file for each page. Is that what you mean by a template? Go here: www.help4newbies.com/template.php . I added the words "INCLUDE" to the comment tags above and below each section of included code. Tell me if it's a correct template.

    weirdbeard: I was planning on writing my own PHP code; that's why I was learning it. But JMulder has given my tons of code, in this thread and another, so I might just end up using his code.

    JMulder: Thanks again for all the code. I think I'm going to end up copying and pasting it. I'll try and understand what it means too. I kinda get the "gist" of it, there's just some things I haven't seen before, yet.

    So, anyways, where should I start? Should I just start putting my tutorials into a database?

    Thanks for all your time!

    Anyone else?
    SPF Mentor/Advisor 2001-2003
    SPF Designer of the Year 2002
    SPF Graphic Designer of the Year 2003
    AdamPolselli.com

  6. #6
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by swimm5001
    weirdbeard and sean: You said to template my page. I think it already is, I'm just not completely sure what it means. I used PHP INLCUDEs for the top banner, side nav., content, and copyright. It's been like that for a while. Then I just change the content in an individual HTML file for each page. Is that what you mean by a template? Go here: www.help4newbies.com/template.php . I added the words "INCLUDE" to the comment tags above and below each section of included code. Tell me if it's a correct template.

    Looks like it is templated! good work.
    weirdbeard: I was planning on writing my own PHP code; that's why I was learning it. But JMulder has given my tons of code, in this thread and another, so I might just end up using his code.
    what i meant was the php-nuke system is actually EVERYTHING you would need -- the whole article/db driven site (rather than say cutting and pasting jmulders code) -- i think the latter is the preferable solution, especially if you make the effort to understand it!

    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  7. #7
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Adam, that's kind of a template as well.

    Basically, however, they mean you have a page (it doesn't even need includes if you don't want it too), that is made up of all of your HTML and things. However, in the content area of your page, instead of having your content as is, you have some PHP and MySQL code.

    Then, depending upon the variables in the URL, MySQL simply calls the data from the database and inserts it into the page, hence where we get "template."

    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  8. #8
    1-800-JMULDER JMulder's Avatar
    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    1,745
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by swimm5001
    ..

    JMulder: Thanks again for all the code. I think I'm going to end up copying and pasting it. I'll try and understand what it means too. I kinda get the "gist" of it, there's just some things I haven't seen before, yet.

    So, anyways, where should I start? Should I just start putting my tutorials into a database?

    Thanks for all your time!

    Anyone else?
    Well, you could write your own Admin Script and add the tutorials from there. When you get the hang of the IF-statements and those different MySQL queries like SELECT, UPDATE etc. it's very easy.

    Also, sorry I gave you the code again, but I am someone who learns from looking at code and not from reading tutorials, so i assumed you would as well

    You can check out various SitePoint Articles on updating, selecting and submitting code to a MySQL db, along with the IF-statements you could easily write your own admin script.

    *cough* I got the code ready *cough*

    LOL, I am using exactly the same system, only I display Vehicles and Download Links

    Check out the system live at http://www.mm2c.com/files/cars/

    Also, working on addding some more functions like:

    http://www.mm2c.com/files/cars/indextest.php?carid=34
    http://www.mm2c.com/files/cars/index...sortby=ShowAll

    A friend of my told me these things is the best you can start learning with because it's used much and you can do some really neat things with it

    Any q's swim5001, ask

    EDIT: Regarding the template thingy, I use a template at my own site, picture is here. It's just a basic page with a bunch of includes and if I would even enter my content into a database, the contenttable would be an include as well.
    Last edited by JMulder; Sep 2, 2001 at 07:13.
    Jeroen Mulder

    w: www.jeroenmulder.com

  9. #9
    Former Staff Member silver trophy Adam P.'s Avatar
    Join Date
    Apr 2001
    Location
    San Francisco
    Posts
    3,288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    K, so I've got my template.

    I know quite a bit of PHP and MySQL (I've gone through Part 5 of Kevin Yanks' tut and I've learned a ton). So I should be able to do this.

    Another question, how many .php files am I going to have? Isn't this going to be like a multi-purpose page?
    SPF Mentor/Advisor 2001-2003
    SPF Designer of the Year 2002
    SPF Graphic Designer of the Year 2003
    AdamPolselli.com

  10. #10
    1-800-JMULDER JMulder's Avatar
    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    1,745
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, for the tutorial viewing page only one..you could use an include though so you would get one include and an index.php

    You could have the Admin Section just in one page but that's a lot of coding.

    As for the multi-purpose thingy, that's all taken care of by MySQL, basically you just load the same page over and over again only MySQL will query for different tables/fields or whatever
    Jeroen Mulder

    w: www.jeroenmulder.com

  11. #11
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by swimm5001
    Another question, how many .php files am I going to have?
    As many as you need!

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  12. #12
    Former Staff Member silver trophy Adam P.'s Avatar
    Join Date
    Apr 2001
    Location
    San Francisco
    Posts
    3,288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, here's what I'm planning:

    I have a database named "Tutorials"

    I have tables named "Tutorials" and "Categories"

    They will look like this:

    Code:
         Tutorials                Categories
    -------------------------   ------------------------
    |ID|   Content      |CID|   |ID|       Name        |
    -------------------------   ------------------------
    | 1| First do this..| 1 |   | 1| HTML              |
    | 2| This tut shows.| 2 |   | 2| CSS               |
    | 3| Start by...    | 1 |   | 3| JavaScript        |
    
    ETC.....
    Get what I'm doing?

    So do you think this will work good?

    Shoot! What about the author? I'm putting some tuts that are submitted. Should I make an "Author" table?

    Also, in my tutorials I have example code. I just typed the code and used <xmp> so that stuff shows. I also use <br>s, different classes (one for the code and one for text). I have images in some of the tuts. Where is all of this going to go? Can I just type HTML tags right in my table entries?

    Thanks
    Last edited by Adam P.; Sep 2, 2001 at 08:57.
    SPF Mentor/Advisor 2001-2003
    SPF Designer of the Year 2002
    SPF Graphic Designer of the Year 2003
    AdamPolselli.com

  13. #13
    Former Staff Member silver trophy Adam P.'s Avatar
    Join Date
    Apr 2001
    Location
    San Francisco
    Posts
    3,288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone? please
    SPF Mentor/Advisor 2001-2003
    SPF Designer of the Year 2002
    SPF Graphic Designer of the Year 2003
    AdamPolselli.com

  14. #14
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    your table ideas, look fine above.

    What you would need to do is have a table that contains the main text of the article (you could break into pages) and have extra columns for things like date submitted, author id, level of difficulty. Then again you could relate the author id to an author table which would have details about them (email address, www site etc.).

    Then when you insert this information into your template it will get formatted automatically (i.e. there won't be any html tags in the table).

    I know this sounds confusing, but its late and I'm tired!

    Will have a better stab at it for you tomorrow.
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky


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
  •