button - Let PHP decide which part of the page to load -
i have 2 buttons. if 1 button clicked, part 1 of file should displayed. when other button clicked, other part should displayed.
and have able switch between pages anytime.
anyone idea how (in php)?
first of all: should express have tried achieve , why things not working. really basic stuff , after reading php manual , html tutorials, should able thing going on own.
the easiest way make buttons include different parameter:
<button onclick="window.location.href='index.php?page=foo';">click me</button> <button onclick="window.location.href='index.php?page=bar';">click me</button>
and read out parameter php:
<?php if (isset($_get['page'])) { switch($_get['page']) { case 'foo': // include page foo break; case 'bar': // include page bar break; } }
disclaimer: said easiest, not most elegant. :)
Comments
Post a Comment