idm1 Posted February 27, 2015 Share Posted February 27, 2015 Hi How can I carry out this code without reloading the page: <ul> <li><a href="?page=1">link 1</a></li> <li><a href="?page=2">link 2</a></li> <li><a href="?page=3">link 3</a></li> <li><a href="?page=4">link 4</a></li> </ul> <?php $page=$_GET['page']; if ($page == '1'){ include 'includes/page1.php'; } if ($page == '2'){ include 'includes/page2.php'; } if ($page == '3'){ include 'includes/page3.php'; } if ($page == '4'){ include 'includes/page4.php'; } ?> Or can someone advise a better way to include and page when a link is clicked? Many thanks Quote Link to comment Share on other sites More sharing options...
rwhite35 Posted February 27, 2015 Share Posted February 27, 2015 If I'm following your logic. when the web user clicks link 1, you want to load "include/page1.php". PHP is a server side technology. In order to run the that pages code, your either have to reload or user a asynchronous programming model like AJAX. AJAX can execute code in the background. Look into JQuery $.ajax as possible solution. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.