Muhammad Hassan
Muhammad Hassan

Reputation: 1304

Pick A DIV Content Of Same Page And Show It On Same Page In PHP

I have a web-page in which there is some text like <h1 class="page-title">Some Text</h1> but I hide it through .page-title{display:none;} as I don't want to show it there. Now I want to show the same Some Text in another DIV of same web-page. This Some Text is dynamic but <h1> tag and class="page-title" is same on every page like <h1 class="page-title">...</h1>. I only want to show it through PHP as I can do it via JavaScript/JQuery.

I Googled many time but every time I am getting the code of picking the DIV content from other page but here I want to pick and show on the same page. Keep in mine the this Some Text is also generated by PHP so I think we need to post it again after this to allow him to load first then pick from there but I want to show it before Some Text on web-page. How to do this?

Upvotes: 0

Views: 655

Answers (2)

Marvin Fischer
Marvin Fischer

Reputation: 2572

You cant execute PHP Script after the page has been loaded at the users browser, do you have all the php script in a variable at php? Then it could be possible to read the value before sending it to the user. Else there is only javascript possible

Upvotes: 1

Katyoshah
Katyoshah

Reputation: 129

You need to add id to h1

    <h1 class="page-title" id="<?php echo $id;?>">some text</h1>  

// $id is the id of "sometext" in your table

Upvotes: 0

Related Questions