Jump to content

[SOLVED] array and links


zang8027

Recommended Posts

I have an array that i will fill with some different values.. these values will refer to an include.

 

I want to have a previous - next link that when you click on one, it refers to a new value.. next or previous value. What this is designed to do is include different files which are stored in a array.

 

So my array looks like:

 

<?php
$myArray = array('article1.php','article2.php');
?>

 

so how can I add a link to schedule.php? Im not sure what to put as a param. Im looking for something like schedule.php?art=1...  if you hit next, it sets art=2. But i also dont want to be able to go to..say art5 if it does not exist in the array

Link to comment
Share on other sites

You'll want to look at the count function to determine how many elements are in the array which will then allow you to determine which links to show.

 

You'll also need to read $_GET['art'] to determine the page you are on.

Link to comment
Share on other sites

thanks, i solved it

 

$myArray = array('voiceMaster.php','voiceMaster.php','voiceMaster.php','voiceMaster.php');

$count = count($myArray);

 

if(isset($_GET['artID']))

{

$currentID = $_GET['artID'];

 

if($_GET['artID'] > 0)

{

$artIDP = $currentID - 1;

$currentID = $_GET['artID'];

 

}else{$artIDP = $currentID;}

 

if($_GET['artID'] < $count)

{

$artIDN = $currentID + 1;

$currentID = $_GET['artID'];

 

}else{$artIDN = $currentID;}

}

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.