Jump to content

Next Button Filtration


e1seix

Recommended Posts

Hello again,

 

having trouble getting this to work:

 

<html>

<head></head>

<body>

 

<?php

 

mysql_connect("blah", "blah", "blah") or die(mysql_error());

mysql_select_db("dogfight_blah") or die(mysql_error());

 

$ID = $_GET['ID'];

$limit=2;

 

$fetch=mysql_query("SELECT * from fragrances WHERE ID=$ID ORDER BY title LIMIT 0, 2")or

die(mysql_error());

$numrows=mysql_num_rows($fetch);

//check if the starting row variable was passed in the URL or not

if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) {

  //we give the value of the starting row to 0 because nothing was found in URL

  $startrow = 0;

//otherwise we take the value from the URL

} else {

  $startrow = (int)$_GET['startrow'];

}

 

//this part goes after the checking of the $_GET var

$fetch = mysql_query("SELECT * FROM fragrances WHERE ID=$ID LIMIT $startrow, 2")or

die(mysql_error());

 

// now you can display the results returned

echo "<table border='0' cellpadding='5' cellspacing='0' width='500'>";

while($row = mysql_fetch_array( $fetch )) {

// Print out the contents of each row into a table

echo "<tr><td align='center' bgcolor='#ffffff' rowspan='2' valign='top' width='125'>";

echo $row['ima_link'];

echo "</td><td align='center' bgcolor='#ffffff' valign='top' width='250'><p class='main_title'>";

echo $row['title'];

echo "</p></td><td align='center' bgcolor='#ffffff' rowspan='2' valign='top' width='125'><p class='main_type'>";

echo $row ['size']. " ". $row['type'];

echo "</p><p class='main_rrp'>RRP £";

echo $row['rrp'];

echo "</p><p class='main_£'>DFUK £";

echo $row['£'];

echo "</p><p class='main_shop'>";

echo $row['SHO'];

echo "</p><p class='main_buttons'>";

echo $row ['cli_link']. $row['buy_link'];

echo "</p></td></tr><tr><td align='center' bgcolor='#ffffff' valign='top' width='250'><p class='main_manufacturer'>";

echo $row['manufacturer'];

echo "</p></td></tr><tr><td align='center' bgcolor='#ffffff' colspan='3' valign='top' width='500'><hr color='#999999' width='95%'></hr>";

echo "</td></tr>";

}

 

echo "</table>";

 

//now this is the link..

if ($startrow>=2) { // bypass PREV link if offset is 0

echo '<a href="'.$_SERVER['PHP_SELF'].'?ID='.$_GET['ID'].'&startrow='.($startrow-2).'"><img src="/PREV.gif" /></a>'; }

 

echo "&nbsp";

 

if ($startrow<=($numrows/$limit)) {

    // not last page so give NEXT link

echo '<a href="'.$_SERVER['PHP_SELF'].'?ID='.$_GET['ID'].'&startrow='.($startrow+2).'"><img src="/NEXT.gif" /></a>'; }

 

 

?>

 

</body>

</html>

 

the limit of rows is 2, the $startrow is defaulted to 0.

 

the problem i keep getting is that this should call 7 results, ie. split over 4 pages as "7 / 2 = 3.5"

 

the "startrows" go up in 2's, so first page startrow=0, second startrow=2, third startrow=4 etc.

 

i cannot get the next button to show up for any page other than the first and it beginning to really bug me now. 7 hours in front of a PC. lol. could do with some idea. :)

 

here's the link: http://www.dogfightuk.com/untitled2.php?ID=4548

 

HELP! lol

Link to comment
https://forums.phpfreaks.com/topic/61567-next-button-filtration/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.