get text from index page to another using php -
is there way text page? here's example
i have index.php , page1.php , page2.php
now on index.php write below create page1 , page2..
<div id="pg1"><a href="page1.php">hello page 1</a></div> <div id="pg2"><a href="page2.php">hello page 2</a></div>
now on page1 , page2 create divs below..
<div id="getpg1">when page1.php opened, here text on index.php on div id pg1. text div</div> <div id="getpg2">when page2.php opened, here text on index.php on div id pg2. text div</div>
hope understand. means when page opened text pointed index.php
sorry, took me moment fix here first. here go:
on index.php
put between <head></head>
:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".page").on("click",function(e){ e.preventdefault(); var link = $(this).attr("href"); var content = $(this).html(); window.location.href = link + "?content=" + content; }); }); </script>
and change divs to:
<div id="pg1"><a href="page1.php" class="page">hello page 1</a></div> <div id="pg2"><a href="page2.php" class="page">hello page 2</a></div>
on page1.php
, page2.php
, use:
<div id="getpg1"><?php echo $_get['content']; ?></div>
Comments
Post a Comment