I’m creating divs with dynamic names using php such as:
echo "<div class=\"".$row['country']."\">"
So it’s going to first create a series of divs such as …
<div class="America">
//stuff goes in here
</div>
<div class="Germany">
//stuff goes in here
</div>
<div class="Singapore">
//stuff goes in here
</div>
But later on in the code after the “Germany” div has already been created, I’m going to make another mysql query to a different table and I want to access the “Germany” class and add content in it. It then becomes something like…
<div class="Germany">
<p> Germany has x number of people </p>
<p> The most popular car in Germany is x </p>
</div>
I know with Jquery there is the append() function. Is there something similar in PHP where I can access a div that’s already been created and add stuff to it?
Note: all of this is in one php file that loads all the content when the page loads.
I think you can create an array like
And in future you can append value to this array. eg.
And finally you can use implode function or using other array functions you can crate final html.