Hi.
The book (PHP & MySQL: Novice to Ninja 6) creates a website with only a few pages each of which tends to display some/all rows in a table in the database, such as all the jokes in the jokes table.
I have a different requirement, not covered by the book.
I have database tables in which each row is a page in itself. For example, I have a table “services” which contains close to a hundred rows, each of which contains all the information about a single service a company offers.
I have set up my navigation to loop through the services table and display a list of links, one for each page. Each link containing the row id. I have created a servicesController which has, an action called display which accepts a query parameter, uses a findById DatabaseTable method to get THAT service and display it.
All this works wonderfully.
My question is this:
I was looking at a specific service page yesterday. I got to the page by clicking a link in my navigation and it produced the following url in the browser’s bar: www.domain.com/service/display?id=1
. I copied the url from the address bar and sent it to a friend so he could take a look at the page. I hadn’t anticipated his reply but once I had it it made perfect sense.
He said he had clicked the link in his email and was taken to www.domain.com
. The site’s homepage.
And of course, I realised there is code in the Framework which grabs the url UP TO THE QUESTION MARK. My links work internally because I am passing the id to a function (no urls invloved). This is how routing works in the framework: no query parameters.
Argh!
- How can I achieve the ability to send a link to a specific page to someone else?
- Am I handling my requirement (to be able to display a single table row as a page rather than display the whole table as a page), correctly within THIS framework?
Thanks, Mike