Hello.

I'm making a tutorial website. Tutorials are stored in a mysql database and their titles are pulled from the database and displayed in a list on the page so the user can click on the title to read the tutorial.

But, because my tutorials flow from "beginner" to "advanced," they need to display on the index page (described above) in that same order.

If i write 5 tutorials, some "advanced", some "beginner", i need to make all the beginner tutorials stay together, and all the advanced tutorials stay together. I've thought of making a category section in the database and using it to seperate the advanced tutorials from the beginner tutorials, but that still wouldn't work because the beginner tutorials still need to be in a certain order; same with the advanced ones.

The only way i can see to do this is to either:

a) Insert all the tutorials in a specific order and never add any more.

or

b) Re-order the rows in the table somehow.

Any suggestions?

Thanks in advance.

    er, hopefully these tutorials won't be for mysql or sql.

    Use the ORDER BY clause.

      lol, no, not for either 😛

      Could you elaborate? or point me to a good tutorial?

      thanks for your help.

        If you need an explicit ordering, and that can't be based on any of your existing columns, then you will need to add columns where you can describe the ordering you want.

        Just posing a hypothetical set of tables (and ignoring grubby details such as indexing!):

            create table category
            (
            id int auto_increment,
            sequence int,
            name text
           &nbsp😉;

            create table article
            (
            id int auto_increment,
            cat_id int, / references category.id /
            sequence int,
            title text,
            contents text
           &nbsp😉;

        Now you can say:

            select category.name, article.title, article.contents
            from category, article
            where category.id = article.cat_id
            order by category.sequence, article.sequence;

          Write a Reply...