1 00:00:04,118 --> 00:00:09,492 Let's create a new div with the class="media-details". 2 00:00:14,695 --> 00:00:17,420 First, we'll put the title within the h1 tags. 3 00:00:28,020 --> 00:00:31,070 Next, we'll create a table with the item details. 4 00:00:37,300 --> 00:00:43,650 We'll start by creating a row for category. 5 00:00:44,700 --> 00:00:46,324 Table header is category. 6 00:00:53,720 --> 00:00:58,218 Now, we'll pull our echo 7 00:00:58,218 --> 00:01:03,130 $item["category"]. 8 00:01:03,130 --> 00:01:04,940 Now, let's copy and past this row three times. 9 00:01:10,359 --> 00:01:11,870 We'll change this for Genre. 10 00:01:15,595 --> 00:01:17,144 Format. 11 00:01:21,349 --> 00:01:22,661 And Year. 12 00:01:26,302 --> 00:01:29,275 These are the shared attributes for all the items in the catalog. 13 00:01:30,410 --> 00:01:34,377 Each of our categories also has some specific attributes. 14 00:01:34,377 --> 00:01:36,755 We'll use a conditional to check our category and 15 00:01:36,755 --> 00:01:39,480 display the attributes associated with each category. 16 00:01:39,480 --> 00:01:43,480 Once again, we'll use our string to lower function to make our categories match. 17 00:01:55,711 --> 00:01:59,027 If the item category ==" books", we'll want to show the authors, 18 00:01:59,027 --> 00:02:00,090 publishers and ISBN. 19 00:02:03,010 --> 00:02:10,430 Let's close off our PHP and we'll open it around our end tag. 20 00:02:10,430 --> 00:02:15,280 Let's copy our category row and paste it three times. 21 00:02:22,023 --> 00:02:25,310 Now we'll switch out Authors, 22 00:02:30,724 --> 00:02:33,375 Publisher. 23 00:02:36,989 --> 00:02:38,165 ISBN. 24 00:02:41,770 --> 00:02:42,570 Let's preview the page now. 25 00:02:42,570 --> 00:02:45,652 You'll see that we have most of our details, but 26 00:02:45,652 --> 00:02:51,320 we're getting a notice array to string conversion, instead of our authors. 27 00:02:51,320 --> 00:02:54,224 Authors are another array nested within our item. 28 00:02:54,224 --> 00:02:57,539 What we want to do is print out a string of each of the authors separated 29 00:02:57,539 --> 00:02:58,120 by a comma. 30 00:02:58,120 --> 00:03:01,330 We could do this with a for each loop like we've done before. 31 00:03:01,330 --> 00:03:05,862 However, we don't want to add anything to the beginning or end of our string, 32 00:03:05,862 --> 00:03:08,200 just in between the elements. 33 00:03:08,200 --> 00:03:13,390 Luckily for us, PHP has another function that will do just that, implode. 34 00:03:13,390 --> 00:03:18,150 Implode takes two parameters and joins the array pieces into a string. 35 00:03:18,150 --> 00:03:22,230 The first parameter is the string you want to use to separate the elements and 36 00:03:22,230 --> 00:03:25,120 the second parameter is the array itself. 37 00:03:25,120 --> 00:03:30,630 The string separator can be anything or group of things such as HTML. 38 00:03:30,630 --> 00:03:33,800 This can be really useful if you want to make a list of items in HTML. 39 00:03:34,880 --> 00:03:36,090 Let's take a look at this in our code. 40 00:03:37,300 --> 00:03:43,230 In this case, we want to echo out implode, a comma and 41 00:03:43,230 --> 00:03:46,910 a space between each of the authors in our array. 42 00:03:50,449 --> 00:03:53,065 Now when we refresh the browser, 43 00:03:53,065 --> 00:03:57,650 we see our list of authors separated by a comma and a space. 44 00:03:58,650 --> 00:04:02,521 We need to add a conditional for our last two categories. 45 00:04:02,521 --> 00:04:04,020 Let's clean up this if line. 46 00:04:09,860 --> 00:04:14,760 And copy it and paste it right before our closing statement. 47 00:04:17,874 --> 00:04:20,930 We'll add a closing curly braces and then an else. 48 00:04:22,020 --> 00:04:25,930 If our category item equals movies. 49 00:04:28,400 --> 00:04:34,290 We're gonna copy one line of Publisher and 50 00:04:34,290 --> 00:04:37,566 change it to Director. 51 00:04:40,729 --> 00:04:44,630 And then we're going to copy our implode. 52 00:04:48,740 --> 00:04:51,735 And paste it two times for 53 00:04:51,735 --> 00:04:58,510 Writers And Stars. 54 00:05:01,860 --> 00:05:06,130 Finally, we'll copy and paste this else if statement one more time. 55 00:05:11,630 --> 00:05:13,120 And change it to music. 56 00:05:15,670 --> 00:05:23,125 We can copy Director and paste this row and change it to Artist. 57 00:05:28,371 --> 00:05:30,290 Now we're ready to preview our page again. 58 00:05:31,390 --> 00:05:33,470 Nothing has changed for our book. 59 00:05:33,470 --> 00:05:39,130 But if we change our ID from 101 to 201, 60 00:05:39,130 --> 00:05:44,860 we see Forrest Gump with our director, writers and stars. 61 00:05:46,030 --> 00:05:49,612 If we change to 301, we see our music of 62 00:05:49,612 --> 00:05:54,070 Beethoven with our artist, Ludwig van Beethoven.