In the article up p.h. prescript we're showing a single article identifying that article by its I.D.
at the moment we've got this I.D. hard coded into the esky well here.
Obviously we don't want to do that.
We want to pass the idea into this script somehow so that we can show any article just by supplying
its side.
So how do we do that.
We can pass it in via the u r l the U R L R uniform resarch locator more commonly known as a web address
typically it looks like this.
The address of the server and the name of the script file.
This is what we've been using so far.
If you add a question mark to the end any text after that is known as the query string we can access
this text inside the script file.
P HP has some built in variables called Super global's that are always available anywhere in a script
the server super global is an array that contains various information about that current script.
One of these is the query string that was used when the page was requested.
Let's create a new file so we can see an example of this.
I'll call it a query string.
Dr T H P in here.
Let's simply dump out the value of the query string like that.
If we access this page in a browser we get an empty string if we add a question mark to the U R L and
then some text then we get that text.
Anything that comes after the question mark is accessible using this variable to query strongest traditionally
used for passing values to a script like this as key value pairs.
So in our script we could process this string to extract the key which is a D and its corresponding
value which is 1.
However there is another super global that we can use to access this data more easily.
They get great returns in associative array of any variables sent like this in the query string.
If we dump out this way in our code like that.
Then in the browser in addition to the entire query string we get an associate of Ray with the key of
idae and it's a value of 1 in this array.
You can add more variables to the query string separated by ampersands like this.
And the ray separates out these variables from the query string into this array for easy access.
You can have several variables here if you like.
But note that they're all passed as strings even though they might be numbers our words are what look
like boolean values.
So going back to our article that p p page instead of having the idea hard coded into the esky well
like this we can pass it through the query string.
Let's concatenate the value from the query string to the end of the Eskew L string like this.
Now in the browser.
If we open our article page and put the idea in the query string like this we get the rijkaard corresponding
to that idae we can change the idae and the record changes.
So we're getting the idea of the rijkaard from the U R L.
Now we've got this.
We can add a link to this article page from our index page passing through the idae in the query string.
Let's make each article title here into a link to articles up p p by wrapping the title in an anchor
tag like this we can access the idea of each rijkaard in the same way they were accessing the other
columns so we can put this in the query string of the U r l like this.
So now the titles of the articles on our index page are links to the article page and if we click on
one it takes us to that individual article.
Each link is different taking us to the same page.
But passing in a different article I find the query string.