We will now create the page that will display the shopping list. First, we will simply create the page with the name of the shopping list.
Take the frame of the home page and create the page /list/index.php
in order to include:
liste2courses.css
stylesheet;We'll retrieve the information regarding the list from the database. In the PHP library, write a new function getListData($db, $id, $key)
which receives parameters :
$db
: the object returned by the dbConnect
function;$id
: the primary key of the list.$key
: the security key to the listThe function retrieves the data from this list from the database. If the
list does not exist or if the key is wrong, use the errorManager
function to display the message "This list does not exist. " before redirecting the user to the home page.
The function must return an array containing 3 keys (id
, name
and ukey
) :
array (size=3)
'id' => string '6' (length=1)
'name' => string 'fsdfsd' (length=6)
'ukey' => string 'fTLx45ryKcMPCjoQEotvg5AUxGrxInf0' (length=32)
Test your function before continuing.
In the list/index.php
page, at the very beginning of the code (before the <!doctype html>
tag)
insert a section in PHP allowing to :
id
and key
);$list
array associated with the requested list using the getListData
function.Once the data is retrieved, replace the temporary title with the name of the list in the header and in the page :