PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Have had a long browse through the net for this but whatever I type I always get the wrong tutorials.
Basically I am looking for a half decent tutorial that show me the rough outlines in which I would need to have dynamic pages ie"index.php?page=animals" and that page pull information from a database.
Sorry for the real nooby questions
Last edited by CONFUSIONUK on Sat Jun 05, 2010 5:58 am, edited 1 time in total.
The way I read it, on line 10 it calls the query line page from includes. I would go to the include page(s) and preface the page with a SELECT query. Or, is your quest how do you write a SELECT query?
I'm really bad at asking questions and being clear sorry, I know how to select and echo tables from the database but like when you see the post i want it to have "read more" at the end of the post when it has been shortend and then clicking the link go to the full post ie "?p=animals&id=1" id being the row in the table....
Hmmm, I hate being dense. The way the referred link works is an HTML page is created with limited content. After the content is the ...<a href='page.php?animal=tiger&id=27'>Read More</a> which when clicked loads a second page which reads the $_GET array and retrieves the requested content.
<?php
// get limited content from wherever
?>
<html>
<head>
<title></title>
</head>
<body>
<p>Limited content goes here. Get it here however and if you want to ...<a href='page.php?page=animals&id=27'>Read More</a></p>
</body>
</html>
Then your second page needs to be something like this
There are a thousand ways of doing this. This is just one way. You can also forgo the second page and incorporate it into the main page using includes or iframes. This should give you a frame to work from.
The row that has the contents of the post is just called 'content' if you needed to know, this seems to be the only bit that has ever puzzled me and is about time I knew how to
OK, try this. Basically it adds another if statement to see if the 'id' element is present and if it is it loads that page instead of the 'p' page. This is rough - you will need to polish some.
that works nicely BUT
where it includes say "?p=home&id=1" it comes up with "Warning: include(1.php) [function.include]: failed to open stream:" but thats because there is no such file i know that, how can i get it to read that post row in the table instead of a file?
Once again thanks so much It would have taken so long to even get that far
Well, I assume that the page that isn't there is going to only handle generic read more stuff, so it one page can be used to display many id=x. Given this I would replace
include $_GET['id'] . '.php';
with
include 'details.php?id=' . $_GET['id'];
which will call a page called 'details.php' with a query string 'id=x'. Create the 'details.php' page to check the $_GET array and query the database based on the id element. Then it will load a page with the required details.