PHP Build a Basic PHP Website Listing and Sorting Inventory Items Creating the Display Function

Ben Os
Ben Os
20,008 Points

My catalog items appear as a long list and suddenly there is no CSS in the site

I am doing the third PHP course and bulding my first non-cms PHP site. I have a very minimalist code (thanks to Alina Holligan) and I seem to did everything right so there are no PHP errors; Till now I also didn't have any CSS-related problems and this is the first time such a thing happens:

For some reason my catalog items appear as a long list and there is no CSS in the site.

Edit: Here are all my codes in one segment:

https://w.trhou.se/33vqtfkc5d

And here is a link to my Treehouse site:

http://port-80-mkqxe69shv.treehouse-app.com/

4 Answers

Dani Bachour
PRO
Dani Bachour
Pro Student 1,977 Points

You forgot to include("inc/header.php"); inside your index.php

Ben Os
Ben Os
20,008 Points

Given that till now all css work I think I deleted this by mistake... Wouldn't it be better to put the link to the css file in Index.php always?

Much thanks for you help!

Dani Bachour
Dani Bachour
Pro Student 1,977 Points

No, it won't. index.php is independent file. header.php is a general file which is used to include CSS (and maybe JavaScript later) into the main web site pages.

Elian Kloppenburg
Elian Kloppenburg
22,903 Points

Hi Ben,

I do not see any link to your CSS sheet in there. So the HTML will be styled without it. It probably belongs in your header.php file ( although not sure, did not take this course yet ) so be sure to check for it.

Ben Os
Ben Os
20,008 Points

Hi Elian, I've updated the Q with a little bit more data. I also expanded about the fact that till now I didn't have any special link to the CSS (not something I noticed) and this is a very new problem. Can you see the further details I added and give me an advice?

Elian Kloppenburg
Elian Kloppenburg
22,903 Points

Can you do me a favor, Ben? Can you snapshot your workspace and post the link here? It's the arrow icon in the top right corner next to the preview button. We will be able to see everything from there and will be able to give you a better solution.

Thanks!

Ben Os
Ben Os
20,008 Points

Oh, thank you Elian, I didn't know this option existed... That's why I copied all this text, Thank you very much for telling me about this!!! Here it is:

https://w.trhou.se/33vqtfkc5d

Ben Os
Ben Os
20,008 Points

In case you didn't see the notification \ We published in the same time - Bumping.

samtruss1986
samtruss1986
11,772 Points

Hi Ben, I hope you got your issue resolved.

When you put the catalog.php file within a sub-directory then the css and img also fail.

I was wondering if there was any code that I would have to modify for this to work.

I have tried the standard ../ beforehand, but the inc file is meant to contain files for a whole site and many large sites have sub directories.

Thank you.

Brian Gilligan
Brian Gilligan
1,540 Points

I had this same issue! It took me forever to find out what was causing it! When I downloaded the data.php file and cut and pasted it in, it didn't include the <?php tag on line 1. Once I added this to the top of the data.php file, it worked again! I hope this helps! Example: <?php //<---THIS IS WHAT WAS MISSING $catalog[101] = [ "title" => "A Design Patterns: Elements of Reusable Object-Oriented Software", "img" => "img/media/design_patterns.jpg", "genre" => "Tech", "format" => "Paperback", "year" => 1994, "category" => "Books",