SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: Help Me PLz!

  1. #1
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help Me PLz!

    I have a website that will be hosting tutorials and scripts!

    On the page where you select which type of tutorial you want to look at ( i.e PHP, ASP, .NET and so on) i want to be able to click a bit of text sayin PHP or ASP and so on and then be able to connect to the database and grab alll the selected fields data!!

    Doing the bit regarding connecting to mysql is fine the only problem i have is The IF statement when a link is clicked.

    Can anyone help me out here??
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    switch($_GET["table"]) {
    case 
    "php":
    $ret mysql_query("SELECT * FROM php");
    break;
    case 
    "asp":
    $ret mysql_query("SELECT * FROM asp");
    break;

    cheers

  3. #3
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The exact query you require depends on

    a) what the link looks like
    b) how the tutorials are stored in the database

    Please post an example of the link and the database table(s) description.

  4. #4
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey swdev, sorry about the late reply I've been on holiday

    Right, the text i want to be able to click on is a standard HTML link.

    I was thinking of using a link to access the tutorial, so whether the script is internal or external (to my site) it can still be viewed.

    ---------------------------------------------------------------------------

    Heres the rough idea of the way id like things to go:

    (Most of this i can manage but there are a few bits that i jus havent got a clue on, but im willing to learn them if neccessary)

    Create a database that holds all the info, here are the coulumns that i will be using: (Not in order)

    id
    TutorialName
    Author
    PostDate
    Rating
    TimesViewed
    Link (to the tutorial)
    TutorialCategory (i.e sessions, authentication)
    TutorialType (i.e PHP, ASP, C/C++)
    Description

    ---------------------------------------------------------------------------

    This is what i want to happen:

    The user clicks on link on the left side of my page (http://www.webnoob.com/phptuts.php) on the particular type of tutorial they would like to see.

    Then inside the currently empty page listed in tables would appear all the categories of that language type.

    The tables would need to be created to allow for the ammount of tutorials and the same with the pages when they are full. So, if i have 1 tutorial i want the page to create 1 table for that info, if i have 6 i want it to create 6 tables and the same with pages, if i can fit 5 tables on the page and i have 10 i want it to create a "next page" link at the bottom to allow me to view the next 5 in the list!

    This routine would be the same for the selection of a tutorial category, so when you have clicked on the sessions category, all the tutorials in the sessions category are displayed in the same way using tables created by the page.

    When the user finally selects which tutorial it is they want to view, they click on the link provided and i think it would be best to take them to a seperate page and it opens it!

    ---------------------------------------------------------------------------

    I'm not asking for a complete ready made script to allow me to do this, i would just like a starting point and maybe some direction as i think it will be quite a complex script!

    Thanks in advance!


    P.S swdev if you have a link you would like me to put on my site i would more thatn happy to do so, as you have helped so much so far!
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  5. #5
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Webnoob

    Hope you had a good holiday

    Rather than have lots of bix boxes on your page, I woud have 1 dropdown box that holds all the tutorials for the selected type (e.g. PHP), and below that, an area where the tutorial is displayed.

    This neatly gets around the pagination problem

    To build the drop-down box, I would use OPTGROUP for each TutorialCategory.

    Here is some sample HTML code that shown you what I mean
    HTML Code:
      <select name="Tutorials">
      <option value="">Select A Tutorial</option>
      
      <optgroup label="PHP-Cat1">
      <option value="tutorial_id">Tutorial 1</option>
      </optgroup>
      
      <optgroup label="PHP-Cat2">
      <option value="tutorial_id">Tutorial 2</option>
      <option value="tutorial_id">Tutorial 3</option>
      </optgroup>
      
      <optgroup label="PHP-Cat3">
      <option value="tutorial_id">Tutorial 4</option>
      <option value="tutorial_id">Tutorial 5</option>
      <option value="tutorial_id">Tutorial 6</option>
      <option value="tutorial_id">Tutorial 7</option>
      </optgroup>
      
      </select>
      
    This is easy to get from the database, with a query somthing like

    PHP Code:
      $sql 'SELECT'
             
    ' id, TutorialName, TutorialCategory'
             
    ' FROM '
             
    ' tutorials '
             
    ' WHERE'
             
    ' TutorialType = \'PHP\''
             
    ' ORDER BY TutorialCategory ASC'
             

    You may want to order this list by, say the date the tutorial was added, so you get later ones at the top of the list.

    Then you just need to grab all the data from this query and insert it into the <select> HTML tag.

    If there are too many tutorials for a single drop-dow list, you can split this list into two parts
    part1 - would be a list of TutorialCategories. Once this has been selected, a 2nd drop-down list could be populated with a list of the relevant tutorials.

    I hope this gives you a starting point

  6. #6
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    once again you have helped a great deal, i like the idea of a dropdown selection.

    Ill get onto it right away (well after ive finished eating cause im hungry )

    You'll no doubt hear from me soon

    Thanks again!!
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  7. #7
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Enjoy your food


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
  •