Showing All User's Poems in on the Poems Page
Duration: 25 to 40 minutes.
In this exercise, you will modify poems.php so that users can see all their own poems, even the ones that have not yet been approved, in the poems table.
- Change the
WHERE clause in both the
$qPoemCount variables to:
WHERE (p.date_approved IS NOT NULL OR u.user_id = ?)
- When first initiation
$currentUserId in the array, like this:
$params = [$currentUserId];
This will result in an effective
WHERE clause of:
WHERE (p.date_approved IS NOT NULL OR u.user_id = $currentUserId)
- Within the
while loop within the
tbody, use the ternary operator to define a
$cls variable. The value should be 'normal' if the
$row['date_approved'] is not null (remember that null is falsy). Otherwise, the value should be 'pending-approval'.
$published is getting a date based on the value of
$row['date_approved']. But if
$published should get "N/A", for not applicable.
- Finally, change the open
<tr> tag to use the