Page 1 of 1

Includes... and if statments?

Posted: Thu Jul 14, 2005 6:56 am
by Fatima
Hello,
I've read several tutorials on php before and I have mostly worked with includes for web site purposes.

Now, however, I need to create a website for books to be viewed online. And making a separate php file for each page of the book(s) is not what I would like to go through. Instead, I thought, there must be a way to just "switch" one part of the website for another - meaning switch on include for another.

So if a person was reading book 1, and clicked on the page 4 link, then the url would look something like books.php?id=1&page=4 and the page include would change to load page 4.

Some one recommended if statements, but I can't seem to get them to work. I understand what they are, but how will they help my website? Most tutorials I have visited on the net talk about if statements for programming purposes and databases.

Any help or a push in the right direction would be most welcome.
I hope my english is clear enough, and sorry if it isn't.

Posted: Thu Jul 14, 2005 7:19 am
by dstefani
Hello,

If your 'books online' project is time sensitive, you may want to hire someone to help you.
If not, then buy a beginners PHP book and begin studying and looking at other peoples code
to see how they do things.

- dstefani

Posted: Thu Jul 14, 2005 7:31 am
by shiznatix

Code: Select all

switch ($_GET['book'])
{
    case "some_book":
        include('some_book/'.$_GET['page'].'.html');//tweak this
        break;
    case "other_book":
        include('other_book'.$_GET['page'].'.html');
        break;
    default:
        include('index.php');
}
see where im going with this? you will only have to have the html page for each page in the book. there are many other ways to do this like load the entire book into a single page then using define() to define a number to a block of text and doing case switch for the id then echoing the id wich would be a defined page with the id number...but maybe thats a little confusing for you right now.