PDA

View Full Version : would this be considered an array?


gavimobile
06-20-2008, 08:10 PM
would this be considered an array?

i remember when i started learning php i read somewhere that an array always starts with 0 instead of 1, is this considered an array? does that apply for this piece of code?

my page is displaying 8 items instead of 9, but when i set it to 10 it displays 9.

tia gavimobile


<?php

$noEntriesQuery = mysql_query("SELECT id FROM table") or die(mysql_error());

// read the number
$noEntries = mysql_num_rows($noEntriesQuery);

// set page limit
$pageLimit = 25;

// calculate the number of pages
$noPages = ceil($noEntries / $pageLimit);

// current page
$currentPage = 0;

// check if the $_GET value exists, if yes.. set the $currentPage to that value
if(isset($_GET['pag']) && is_numeric($_GET['pag']) && $_GET['pag'] > 0 && $_GET['pag'] < $noPages){

// the test passed, set the current page
$currentPage = $_GET['pag'];
}

// start number
$start = $currentPage * $pageLimit;

// the query for the current page
$sql = "SELECT * FROM yable ORDER by id LIMIT ".$start.",".$pageLimit;

?>

davidj
06-20-2008, 08:39 PM
an array is a container which holds data and to access that data you need an index or a key.

the above as a whole does not constitute an array

gavimobile
06-20-2008, 09:26 PM
an array is a container which holds data and to access that data you need an index or a key.

the above as a whole does not constitute an array

so why would it make sence for the creator of this script to start with 0 instead of 1?

davidj
06-20-2008, 09:43 PM
the LIMIT in your SQL has 2 values with the first being the offset which starts at 0 as its the first record