this question is common, accually so common that someone asked this same
question earlier today, read the previous posts before asking. phpbuilder
also has a tutorial, look around the web before posting too.

  if (!isset($HOW_MANY))
    $HOW_MANY = 10;
  if (!isset($position))
    $position = 0;

  $prev = $position - $HOW_MANY;
  $next = $position + $HOW_MANY;

  $query = "SELECT * FROM table LIMIT $position, $HOW_MANY";

  $search_a = $position;
  $search_b = $next;
  $search_c = @$product->product_count;

  if ($search_b > $search_c)
    $search_b = $search_c;

  echo "
  Displaying $search_a - $search_b of $search_c Orders
  ";

  if ($prev >= 0)
    echo "
    <a href='$PHP_SELF?position=$prev'><$IMG src='image/back.gif'></a>
    ";
  echo "
  <a href='$PHP_SELF?position=0'><$IMG src='image/home.gif'></a>
  ";
  if ( $next < $search_c )
    echo "
    <a href='$PHP_SELF?position=$next'><$IMG src='image/next.gif'></a>
    ";


--

  Chris Lee
  [EMAIL PROTECTED]


"Mick Fitzpatrick" <[EMAIL PROTECTED]> wrote in message
005801c14db9$6bfe4900$0100a8c0@garage">news:005801c14db9$6bfe4900$0100a8c0@garage...
> Hello
>
> After several days of reading various articles on the web I've 'finally'
got
> a basic database working. The database is for a massive collection of my
> vinyl records. Therefore I would like to limit the results to about 20 per
> page and move forward/backward with 'next' and 'previous' links.
>
> I'd like to stress at this stage that I'm new to PHP and don't really know
> and 'tech speak' related to it ... however I like to think I'm a quick
> learner :-)
>
> Below I've pasted a copy of the script I fashioned ... I suppose it's full
> of mistakes but it does work!
>
> Any assistance will be appreciated
>
> TIA ... Mick
>
> ***********************************
>
> <html>
> <body>
>
> <table border="1" width="100%" cellspacing="0"><TR><TH><font
> face=Arial>artists</TH><TH><font face=Arial>aside</TH><TH><font
> face=Arial>bside</TH><TH><font face=Arial>label</TH><TH><font
> face=Arial>number</TH><TH><font face=Arial>price</TH><TH><font
> face=Arial>origin</TH><TH><font face=Arial>format</TH><TH><font
> face=Arial>info</TH></TR>
>
>
> <?php
>
> file://THIS BLOCK IS THE MySQL DATABASE INFO AND LOCATION
> mysql_connect ("xxxxxxxxxxxxxxx", "xxxxxc", "xxxxxx");
> mysql_select_db ("xxxxxx");
>
> if ($artists == "")
> {$artists = '%';}
>
> if ($aside == "")
> {$aside = '%';}
>
> if ($bside == "")
> {$bside = '%';}
>
> if ($label == "")
> {$label = '%';}
>
> if ($number == "")
> {$number = '%';}
>
>
> file://THIS ROW SETS THE SEARCH CRITERIA AND THE ORDER ITS DISPLAYED ASC
is
> ASCENDING
> $result = mysql_query ("SELECT * FROM example WHERE artists LIKE
'$artists%'
> AND aside LIKE '$aside%' AND bside LIKE '$bside%' AND label LIKE '$label%'
> AND number LIKE '$number%' ORDER BY artists ASC");
>
> if ($row = mysql_fetch_array($result)) {
>
> do {
>
>
> file://THIS BLOCK DEFINES THE ALTERNATE ROW COLOURS
> $darkcolor="#EEEEEE";
> $lightcolor="#FFFFFF";
> $test=$colorcount%2;
> if ($test==0){
> $rowcolor=$darkcolor;}
> else{
> $rowcolor=$lightcolor;}
> $colorcount++;
>
> file://THIS BLOCK PUTS THE SEARCH RESULTS IN THE TABLE
> echo("<tr valign=top bgcolor=$rowcolor></TD><TD><font size=1 face=Arial>"
.
> $row["artists"] . "</TD><TD><font size=1 face=Arial>" . $row["aside"] .
> "</TD><TD><font size=1 face=Arial>" . $row["bside"] . "</TD><TD><font
size=1
> face=Arial>" . $row["label"] . "</TD><TD><font size=1 face=Arial>" .
> $row["number"] . "</TD><TD><font size=1 face=Arial>" . $row["price"] .
> "</TD><TD><font size=1 face=Arial>" . $row["origin"] . "</TD><TD><font
> size=1 face=Arial>" . $row["format"] . "</TD><TD><font size=1 face=Arial>"
.
> $row["info"] . "</TD></TR>");
>
> } while($row = mysql_fetch_array($result));
>
> } else {print "<font face=Arial>Sorry, no records were found!";}
>
> ?>
>
> </body>
> </html>
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to