Display certian attributes in one php include, and all divs in another

I have some content stored in php files that I want to include two places on my page. Firstly, I want to include all the content, but secondly, I just want to include the content in certain divs with a given class.

For example, I have the following files:

index.php
content.php
list.php
problems.php

index.phphave the following contents: <?php include "list.php"; include "problems.php"; ?>.

Both list.phpand problems.phpcontain<php include "content.php"; ?>

content.php have the following contents:

<div class="up">This location is up</div>
<div class="down">This location is down</div>

How can I display all content content.phpwith list.phpand display only content with div class="down"in problems.php?

I tried to add

<style>
.up {display:none}
</style>

in problems.php, but it removed all div class="up"of both inclusions.

Thank!

+4
2

,

.php

<div id='problems'><php include "content.php"; ?></div>
<style>
   #problems .up {display:none}
</style>
+1

include_once().

include_once script. include, , , . , .

0

Source: https://habr.com/ru/post/1584854/


All Articles