CSV with page numbering problem
Posted: Sat Dec 26, 2009 5:28 pm
Hi, i am new here and i am working on this script trying to fine tune it.
The problem is that i had this script for a while and thought it worked but it doesn't for the fully 100%.
It reads it's data from a CSV, than it shows certain entries from that CSV, that works, but when i use a page numbering script in it, it loops the same page.
(by page numbering i mean previous and next buttons)
The part: if ( $parts[5] == 5400) is the part where it loads a certain piece of the CSV, a certain row where all the entries of part5 have the number 5400 in it.
But it needs brackets, like this {
If i remove those brackets the page (next) and (previous) works, but when i put it the brackets in, the next and previous button continuously show the same 6 products over and over again.
How can i fix this ?
Can someone please help me
What i want is that the results from the if ( $parts[5] == 5400) is page numbered. (so that the next and previous buttons work)
Here is my script:
The problem is that i had this script for a while and thought it worked but it doesn't for the fully 100%.
It reads it's data from a CSV, than it shows certain entries from that CSV, that works, but when i use a page numbering script in it, it loops the same page.
(by page numbering i mean previous and next buttons)
The part: if ( $parts[5] == 5400) is the part where it loads a certain piece of the CSV, a certain row where all the entries of part5 have the number 5400 in it.
But it needs brackets, like this {
If i remove those brackets the page (next) and (previous) works, but when i put it the brackets in, the next and previous button continuously show the same 6 products over and over again.
How can i fix this ?
Can someone please help me
What i want is that the results from the if ( $parts[5] == 5400) is page numbered. (so that the next and previous buttons work)
Here is my script:
Code: Select all
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body bgcolor=#E2E965 link=#812990 vlink=#812990 alink=#812990 text=black>
</html>
<?PHP
$offset = isset($_GET['offset'])?$_GET['offset']:0;
$LinesToDisplay = 6;
$row = $offset + $LinesToDisplay;
$row2 = $offset - $LinesToDisplay;
$file_handle = fopen("web.txt", "rb");
while ((($parts = fgetcsv($file_handle,4096,"|")) !== FALSE) && ($LinesToDisplay > 0) &&
(!feof($file_handle)))
{
//new code
//skip first $offset lines
if ($offset-- > 0)
{
continue;
}
///////////////////////////
if ($parts[5] == 5400)
{
$parts[0] = ucwords(strtolower($parts[0]));
$parts[1] = ucwords(strtolower($parts[1]));
echo "<p><a class='popup4' href='#'><font size=-1
face=Humanist777BT-ExtraBlackB><b>$parts[0]</b></font>";
echo "<table><tr><td><i>";
echo "<span class='comment'>$parts[1]</span></td></tr></table></i></a>";
echo "<TABLE BORDER='0' cellpadding='0' CELLSPACING='0'><TR><TD WIDTH='70'
HEIGHT='20' BACKGROUND='pricebackground.jpg' VALIGN='bottom'><center><font
color=white>€". $parts[2] ."</center></td></tr></table>";
echo "<b><font size=3 color=#D7182A>Op Voorraad In:<br></font>";
echo (" Amsterdam ");
if ( $parts[3] >= 1 ) echo ("<IMG SRC =green.gif>")."";
if ( $parts[3] == 0 ) echo ("<IMG SRC =red.gif>")."";
echo (" Utrecht ");
if ( $parts[4] >= 1 ) echo ("<IMG SRC =green.gif>")."<div
class='spacer_black'></div></b>";
if ( $parts[4] == 0 ) echo ("<IMG SRC =red.gif>")."<div
class='spacer_black'></div></b>";
}
//new code
//By here we decrement the line to display, when this reaches 0 the loop will stop
$LinesToDisplay--;
//////////////////////////////
}
fclose($file_handle);
?>
<html>
<BR><a href="occasionb.php?offset=<?php echo $row2;?>">Previous</a> - <a
href="occasionb.php?offset=<?php echo $row;?>">Next</a></html>