PHP Stack Array Push & Pop -
ive been trying create navigation system project have been working on. i've been stuck while now, feel i'm on right track.
i want know how make when user selects sql1.php removed $phpfiles same page wont appear again href. it's set random, fine want, never want user see same link twice.
<?php $currentpage = $_server["php_self"]; $nextpage; $prevpage; $phpfiles = array(); $phpfilesprevious = array(); $phpfiles[] = 'sql1.php'; $phpfiles[] = 'sql2.php'; $phpfiles[] = 'sql3.php'; $phpfiles[] = 'sql4.php'; $phpfiles[] = 'sql5_1.php'; $phpfiles[] = 'sql6.php'; $phpfiles[] = 'sql7.php'; $phpfiles[] = 'sql8.php'; $phpfiles[] = 'sql9.php'; $phpfiles[] = 'sql10.php'; $nextpage=$phpfiles[rand(0, count($phpfiles)-1)]; $prevpage=$currentpage; $currentpage=$nextpage; array_push($phpfilesprevious, $currentpage); array_push($phpfilesprevious, $prevpage); unset($phpfiles[$nextpage]); $prevpage=array_pop($phpfilesprevious); array_push($phpfiles, $prevpage); function push($phpfiles, $currentpage, $nextpage) { array_push($phpfiles, $currentpage); unset($phpfiles[$nextpage]); } if(isset($_post['next'])) { echo $nextpage; echo $prevpage; } if(isset($_get['dec'])) { // decreasing --$_session['count']; echo --$_session['count']; } $_session["count"]; if ($_session['count'] <=0) { echo '<button><a href="#">current page - ' . $currentpage . '</a> </button>'; echo '<button name = "next" id = "next"> <a href="' . $nextpage . '"">next page - ' . $nextpage . '</a> </button>'; } else if ($_session['count'] < 10) { echo '<button> <a href="' . $prevpage . '?dec=true" onclick="" class="">previous</a></button>'; echo '<button> <a href="#">current page - ' . $currentpage . '</a> </button>'; echo '<button name = "next" id = "next"> <a href="' . $nextpage . '"">next page - ' . $nextpage . '</a> </button>'; } else { echo '<button> <a href="' . $prevpage . '?dec=true" onclick="" class="">previous</a></button>'; echo '<button> <a href="#">current page - ' . $currentpage . '</a> </button>'; } ?>
Comments
Post a Comment