Scripts

vorige volgende met artikel link

het script van http://www.phphulp.nl/php/scripts/2/123/ heb ik aangepast, zodat het gebruikt kan worden om b.v. 6 producten weer te geven en dat er van deze producten weer een link gemaakt wordt om daarna de detail informatie op te vragen. Het enige probleem is dat het script werkt, maar ipv 6 nu 5 producten weergeeeft (de eerste wordt niet opgeroepen). Wie weet er raad? (het probleem zit in '//create list block of results', maar ik kom er echt niet uit.

vorige-volgende-met-artikel-link
<?
// Connect to the Databaseserver 
mysql_connect ("","",""); 

// Select the Database 
mysql_select_db(""); 

// Variables 
if(is_numeric($_GET['max'])) $max = $_GET['max']; 
if(is_numeric($_GET['start'])) $start = $_GET['start'];  

if (empty($max)) $max = 6;  // $max is the maximum number of results per page 
if (empty($start)) $start = 0; // This is the number to start the query at the right location [DO NOT EDIT] 

// Calculate some stuff 
$end = $start + $max;   // This is for the query, gives the number for the LIMIT 
$prev = $start - $max;   // This number is for $start in the Previous-hyperlink 
$next = $end;   // This number is for $start in the Next-hyperlink 

// Select everything from the table 
$query = mysql_query("SELECT ID, NR, artikel FROM catalogus ORDER BY ID, NR, artikel DESC LIMIT $start, $max") or die (mysql_error()); 

// Number of rows from $query 
$num = mysql_num_rows($query);  
if (empty($num))  
{ 
   echo "<p>Geen producten geselecteerd.</p>"; 
} 
else 
{ 
  while ($result = mysql_fetch_row($query))  
  {  

//create list block of results    
$contact_list ="<ul>";
while ($row = mysql_fetch_array($query)) {
	$ID = $row['ID'];
	$NR = $row['NR'];
	$artikel = $row['artikel'];
	$contact_list .= "<li><a href=\"show_contact.php?id=$ID\">$NR, $artikel</a>";
}
$contact_list .="</ul>";
// echo "[$result[0]] $result[1]<br>\n";   
 echo "$contact_list";
	};
	echo "<p>\n";  
   
  // Check if $prev is higher than or equal to 0, if so add the Previous-hyperlink 
  if ($prev >= '0') 
  { 
     echo "[<a href=\"test4.php?start=$prev&max=$max\">Previous</a>]\n"; 
  } else { 
     echo "[Previous]\n"; 
  } 
   
  // Count how many rows there are in the table 
  $count = mysql_fetch_row(mysql_query("SELECT count(*) FROM catalogus")); 

  // Calculate on which page we are 
  $thispage = ceil($start/$max+1); 

  // If $count[0] is higher than $max, show the pagenumbers 
  if ($count[0] > $max) 
  { 
     // Calculate the amount of pages 
     $total = ceil($count[0]/$max); 
     for($i=0;$i<$total;$i++) 
     { 
          // The number to show has to be $1+1 (because $i starts with 0) 
          $number  = $i+1; 
          // $start has to be $i * $max 
          $start = $i*$max; 

         // If thispage is equal to the number, the link has to be bold 
         if ($thispage == $number) 
          { 
           echo "<strong>[<a href=\"test4.php?start=" . $start . "&max=" . $max . "\">" . $number . "</a>]</strong>\n"; 
         } else { 
           echo "<a href=\"test4.php?start=" . $start . "&max=" . $max . "\">" . $number . "</a>\n"; 
         } 
     } 
  } 

  // If $count[0] is higher than $next, show the hyperlink 
  if ($count[0] > $next) 
  { 
     echo "[<a href=\"test4.php?start=$next&max=$max\">Next</a>]\n"; 
  } else { 
     echo "[Next]\n"; 
  } 
  echo "</p>\n"; 
} 
?>

Reacties

0
Nog geen reacties.