SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 33
  1. #1
    SitePoint Enthusiast jenny28's Avatar
    Join Date
    Dec 2004
    Location
    Seattle
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile Next Page Help!!

    Hi everyone! I'm new to posting on forums for help, so let me know if I do it wrong. I wrote some PHP pages by reading through tutorials and such, but I'm having one problem. All I want to do is get the part of my display page that says "Previous" to link to the page before and "Next" after. I found all these different tutorials on pagination, but I must be doing something really wrong because I get nothing but errors. I don't want it to be like this: Previous 1 2 3 4 Next....all I want is Previous to go back 1, Next to go forward 1. It seems simple, but alas.... Can anyone help me figure this out? Here is my script - where would I put the code and what should it say? Thank you all so much if you can help me!!!!!

    Code:
    <?
    $host="localhost";
    $user="test_user";
    $password="test_pw";
    $dbname="test_db";
    $dbtable="test_table";
    
    $homepage="enternew.php";
    
    $dbh=mysql_connect ("localhost", "test_user", "test_pw") or die ('I cannot connect to the database because: ' . mysql_error());
    mysql_select_db ("test_db");
    ?>
    <html>
    <head>
    <title>site</title>
    </head>
    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <?
    $sql = "select id,first,last,thumba,thumbb,thumbc,thumbd,team,number,league,year,home,brand,loa,size,description,draft,current from $dbtable where id=$id;";
    	$result = mysql_query($sql, $dbh) or die( mysql_error() );
    
    $first = mysql_result($result, 0, "first");
    $last = mysql_result($result, 0, "last");
    $thumba = mysql_result($result, 0, "thumba");
    $thumbb = mysql_result($result, 0, "thumbb");
    $thumbc = mysql_result($result, 0, "thumbc");
    $thumbd = mysql_result($result, 0, "thumbd");
    $team = mysql_result($result, 0, "team");
    $number = mysql_result($result, 0, "number");
    $league = mysql_result($result, 0, "league");
    $year = mysql_result($result, 0, "year");
    $home = mysql_result($result, 0, "home");
    $brand = mysql_result($result, 0, "brand");
    $loa = mysql_result($result, 0, "loa");
    $size = mysql_result($result, 0, "size");
    $description = mysql_result($result, 0, "description");
    $draft = mysql_result($result, 0, "draft");
    $current = mysql_result($result, 0, "current");
    
    ?>
    &nbsp;
    &nbsp;
    <table width="100%" border="0" cellspacing="10" cellpadding="0">
      <tr> 
        <td valign="top">
    	
    	<table width="100%" height="30" border="0" cellpadding="0" cellspacing="3">
            <tr> 
              <td>Previous</td>
              <td>Home</td>
              <td>Next</td>
            </tr>
          </table></td>
      </tr>
      <tr> 
        <td> <table width="100%">
            <tr> 
              <td colspan="4"><? print "$first"; ?> <? print "$last"; ?></td>
            </tr>
            <tr> 
              <td colspan="4"><table width="100%" border="0" cellspacing="2" cellpadding="0">
                  <tr> 
                    <td><? print "$thumba"; ?> </td>
                    <td><? print "$thumbb"; ?> </td>
                    <td><? print "$thumbc"; ?> </td>
                    <td><? print "$thumbd"; ?> </td>
                  </tr>
                </table></td>
            </tr>
            <tr> 
              <td>Team</td>
              <td>Number</td>
              <td>League</td>
              <td>Year</td>
            </tr>
            <tr> 
              <td><? print "$team"; ?></td>
              <td><? print "$number"; ?></td>
              <td><? print "$league"; ?></td>
              <td> <? print "$year"; ?></td>
            </tr>
            <tr> 
              <td>Home</td>
              <td>Brand</td>
              <td>LOA</td>
              <td>Size</td>
            </tr>
            <tr> 
              <td><? print "$home"; ?></td>
              <td><? print "$brand"; ?></td>
              <td><? print "$loa"; ?></td>
              <td> <? print "$size"; ?></td>
            </tr>
            <tr> 
              <td colspan="4">Description</td>
            </tr>
            <tr> 
              <td colspan="4"><? print "$description"; ?></td>
            </tr>
            <tr> 
              <td colspan="2">Draft</td>
              <td height="21" colspan="2">Current</td>
            </tr>
            <tr> 
              <td colspan="2"><? print "$draft"; ?></td>
              <td colspan="2"><? print "$current"; ?></td>
            </tr>
          </table></td>
      </tr>
    </table>
    </body>
    </html>

  2. #2
    SitePoint Member baburaj's Avatar
    Join Date
    Sep 2004
    Location
    india
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why don't you try this code



    <?
    $host="localhost";
    $user="test_user";
    $password="test_pw";
    $dbname="test_db";
    $dbtable="test_table";

    $homepage="enternew.php";

    $dbh=mysql_connect ("localhost", "test_user", "test_pw") or die ('I cannot connect to the database because: ' . mysql_error());
    mysql_select_db ("test_db");
    ?>
    <html>
    <head>
    <title>site</title>
    </head>
    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <?

    if($hdAction==1)
    {

    $sql = "select id,first,last,thumba,thumbb,thumbc,thumbd,team,number,league,year,home,brand,l oa,size,description,draft,current from $dbtable where id=$id LIMIT $Start,$PerPage;";
    $result = mysql_query($sql, $dbh) or die( mysql_error() );

    }
    else
    {
    $sql = "select id,first,last,thumba,thumbb,thumbc,thumbd,team,number,league,year,home,brand,l oa,size,description,draft,current from $dbtable where id=$id LIMIT $Start,$PerPage;";
    $result = mysql_query($sql, $dbh) or die( mysql_error() );
    }
    $first = mysql_result($result, 0, "first");
    $last = mysql_result($result, 0, "last");
    $thumba = mysql_result($result, 0, "thumba");
    $thumbb = mysql_result($result, 0, "thumbb");
    $thumbc = mysql_result($result, 0, "thumbc");
    $thumbd = mysql_result($result, 0, "thumbd");
    $team = mysql_result($result, 0, "team");
    $number = mysql_result($result, 0, "number");
    $league = mysql_result($result, 0, "league");
    $year = mysql_result($result, 0, "year");
    $home = mysql_result($result, 0, "home");
    $brand = mysql_result($result, 0, "brand");
    $loa = mysql_result($result, 0, "loa");
    $size = mysql_result($result, 0, "size");
    $description = mysql_result($result, 0, "description");
    $draft = mysql_result($result, 0, "draft");
    $current = mysql_result($result, 0, "current");

    ?>
    &nbsp;
    &nbsp;
    <form name="form1" method="post" action="">
    <table width="100%" border="0" cellspacing="10" cellpadding="0">
    <tr>
    <td valign="top">

    <table width="100%" height="30" border="0" cellpadding="0" cellspacing="3">
    <tr>
    <td><a href="database.php?hdAction=1&id=<? print mysql_result($result, 0, "id");?>-1">Previous</a></td>
    <td>Home</td>
    <td><a href="database.php?hdAction=1&id=<? print mysql_result($result, 0, "id");?>+1" >Next</a>

    <input type="hidden" name="hdAction">
    <input type="hidden" name="Ident"> </td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td> <table width="100%">
    <tr>
    <td colspan="4"><? print "$first"; ?> <? print "$last"; ?></td>
    </tr>
    <tr>
    <td colspan="4"><table width="100%" border="0" cellspacing="2" cellpadding="0">
    <tr>
    <td><? print "$thumba"; ?> </td>
    <td><? print "$thumbb"; ?> </td>
    <td><? print "$thumbc"; ?> </td>
    <td><? print "$thumbd"; ?> </td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td>Team</td>
    <td>Number</td>
    <td>League</td>
    <td>Year</td>
    </tr>
    <tr>
    <td><? print "$team"; ?></td>
    <td><? print "$number"; ?></td>
    <td><? print "$league"; ?></td>
    <td> <? print "$year"; ?></td>
    </tr>
    <tr>
    <td>Home</td>
    <td>Brand</td>
    <td>LOA</td>
    <td>Size</td>
    </tr>
    <tr>
    <td><? print "$home"; ?></td>
    <td><? print "$brand"; ?></td>
    <td><? print "$loa"; ?></td>
    <td> <? print "$size"; ?></td>
    </tr>
    <tr>
    <td colspan="4">Description</td>
    </tr>
    <tr>
    <td colspan="4"><? print "$description"; ?></td>
    </tr>
    <tr>
    <td colspan="2">Draft</td>
    <td height="21" colspan="2">Current</td>
    </tr>
    <tr>
    <td colspan="2"><? print "$draft"; ?></td>
    <td colspan="2"><? print "$current"; ?></td>
    </tr>
    </table></td>
    </tr>
    </table> </form>
    </body>
    </html>
    Arbe

  3. #3
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If your pages (or records) are numbered one by one 1,2,3... to $max_page, previous/next "algorithm" is as easy as

    PHP Code:
    if($current_page 1)
       
    printf("<a href='?page=%d'>back</a>"$current_page 1);
    if(
    $current_page $max_page)
       
    printf("<a href='?page=%d'>next</a>"$current_page 1); 
    And throw away your mysql_result bunch, use one of mysql_fetch_ functions instead.

  4. #4
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    Sutton, Surrey
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For a tutorial on pagination which shows two different approaches take a look at [Advisor edit]Tony, your are not allowed to link to your own site, even if it is answering the question. Sorry. -Helge[/Advisor edit]
    Last edited by Helge; Dec 3, 2004 at 11:59. Reason: Removed link

  5. #5
    SitePoint Enthusiast jenny28's Avatar
    Join Date
    Dec 2004
    Location
    Seattle
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    error message

    Hi again! Thanks to EVERYONE for your help.
    I tried out the script and got this error message...does anyone know what it means?

    You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

  6. #6
    SitePoint Member
    Join Date
    Dec 2004
    Location
    Piura - Perú
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Force the script to show the sql string:
    PHP Code:
    $result mysql_query($sql$dbh) or die( "Error in <b>$sql</b>. Mysql says"mysql_error() ); 
    Last edited by jpinedo; Dec 2, 2004 at 14:34.
    Paginator 1.5 An easy pagination script. (in spanish)

  7. #7
    SitePoint Enthusiast jenny28's Avatar
    Join Date
    Dec 2004
    Location
    Seattle
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    error message reads

    WOW...i'm really learning a lot with everyone's help! Thank you! Here's what the message reads as with that code in place:

    Error in select id,first,last,thumba,thumbb,thumbc,thumbd,team,number,league,year,home,brand,loa,size,description,draft,current from test_table where id=18 LIMIT ,;. Mysql saysYou have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

  8. #8
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmmm...
    the code that was provided seemed good, could you please provide a link tothe site, and if possible give us your current code that is causing an error?
    And by the way, welcome to the forums

  9. #9
    SitePoint Enthusiast jenny28's Avatar
    Join Date
    Dec 2004
    Location
    Seattle
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Codes

    Thanks! You guys have been so great about helping me! I read through a lot of previous posts trying to find some answers and I thought I would really annoy everyone here because I didn't know what I was talking about! But everyone has been so nice and helpful! It really makes it easier to learn when you don't geel guilty about asking questions.

    I have 2 pages: main.php is like the index. It will show a list of the individual pages a person can view. So, when you click on a name, it will take you to display_jersey.php?and the page number here. This is the page that will have the previous and next links. That way a person doesn't have to go back to the main page to see the next item, they just click forward or back!

    main.php:
    Code:
    <?
    $host="localhost";
    $user="test_user";
    $password="test_pw";
    $dbname="test_db";
    $dbtable="test_table";
    
    $dbh=mysql_connect ("localhost", "test_user", "test_pw") or die ('I cannot connect to the database because: ' . mysql_error());
    mysql_select_db ("test_db");
    ?>
    <html>
    <head>
    <title>site</title>
    
    </head>
    
    <body>
    
    <table width="100%" border="0" cellspacing="10" cellpadding="0">
      <tr> 
        <td> 
          <?
    $sql = "select id, first, last from $dbtable order by id desc;";
    $result = mysql_query($sql, $dbh) or die( mysql_error() );
    for ($x = 0; $x < mysql_num_rows($result); $x++)
    {
    	$id = mysql_result($result, $x, "id");
    	$first = mysql_result($result, $x, "first");
    	$last = mysql_result($result, $x, "last");
    	
    	print "<tr bordercolor='#FFFFFF'>";
    	print "<td><a href='display_jersey.php?id=$id'>$first $last</a></td>";
    	print "</tr>";
    }
    ?>
        </td>
      </tr>
    </table>
    </body>
    </html>

    display_jersey.php:
    Code:
    <?
    $host="localhost";
    $user="test_user";
    $password="test_pw";
    $dbname="test_db";
    $dbtable="test_table";
    
    $homepage="enternew.php";
    
    $dbh=mysql_connect ("localhost", "test_user", "test_pw") or die ('I cannot connect to the database because: ' . mysql_error());
    mysql_select_db ("test_db");
    ?>
    <html>
    <head>
    <title>site</title>
    </head>
    <body>
    <?
    
    if($hdAction==1)
    {
    
    $sql = "select id,first,last,thumba,thumbb,thumbc,thumbd,team,number,league,year,home,brand,loa,size,description,draft,current from $dbtable where id=$id LIMIT $Start,$PerPage;";
    $result = mysql_query($sql, $dbh) or die( "Error in <b>$sql</b>. Mysql says". mysql_error() );
    
    }
    else
    {
    $sql = "select id,first,last,thumba,thumbb,thumbc,thumbd,team,number,league,year,home,brand,loa,size,description,draft,current from $dbtable where id=$id LIMIT $Start,$PerPage;";
    $result = mysql_query($sql, $dbh) or die( "Error in <b>$sql</b>. Mysql says". mysql_error() );
    }
    $first = mysql_result($result, 0, "first");
    $last = mysql_result($result, 0, "last");
    $thumba = mysql_result($result, 0, "thumba");
    $thumbb = mysql_result($result, 0, "thumbb");
    $thumbc = mysql_result($result, 0, "thumbc");
    $thumbd = mysql_result($result, 0, "thumbd");
    $team = mysql_result($result, 0, "team");
    $number = mysql_result($result, 0, "number");
    $league = mysql_result($result, 0, "league");
    $year = mysql_result($result, 0, "year");
    $home = mysql_result($result, 0, "home");
    $brand = mysql_result($result, 0, "brand");
    $loa = mysql_result($result, 0, "loa");
    $size = mysql_result($result, 0, "size");
    $description = mysql_result($result, 0, "description");
    $draft = mysql_result($result, 0, "draft");
    $current = mysql_result($result, 0, "current");
    
    ?>
    &nbsp;
    &nbsp;
    <form name="form1" method="post" action="">
    <table width="100%" border="0" cellspacing="10" cellpadding="0">
    <tr> 
    <td valign="top">
    
    <table width="100%" height="30" border="0" cellpadding="0" cellspacing="3">
    <tr> 
    <td><a href="display_jersey.php?hdAction=1&id=<? print mysql_result($result, 0, "id");?>-1">Previous</a></td>
    <td>Home</td>
    <td><a href="display_jersey.php?hdAction=1&id=<? print mysql_result($result, 0, "id");?>%2B1" >Next</a>
    
    <input type="hidden" name="hdAction">
    <input type="hidden" name="Ident"> </td>
    </tr>
    </table></td>
    </tr>
    <tr> 
    <td> <table width="100%">
    <tr> 
    <td colspan="4"><? print "$first"; ?> <? print "$last"; ?></td>
    </tr>
    <tr> 
    <td colspan="4"><table width="100%" border="0" cellspacing="2" cellpadding="0">
    <tr> 
    <td><? print "$thumba"; ?> </td>
    <td><? print "$thumbb"; ?> </td>
    <td><? print "$thumbc"; ?> </td>
    <td><? print "$thumbd"; ?> </td>
    </tr>
    </table></td>
    </tr>
    <tr> 
    <td>Team</td>
    <td>Number</td>
    <td>League</td>
    <td>Year</td>
    </tr>
    <tr> 
    <td><? print "$team"; ?></td>
    <td><? print "$number"; ?></td>
    <td><? print "$league"; ?></td>
    <td> <? print "$year"; ?></td>
    </tr>
    <tr> 
    <td>Home</td>
    <td>Brand</td>
    <td>LOA</td>
    <td>Size</td>
    </tr>
    <tr> 
    <td><? print "$home"; ?></td>
    <td><? print "$brand"; ?></td>
    <td><? print "$loa"; ?></td>
    <td> <? print "$size"; ?></td>
    </tr>
    <tr> 
    <td colspan="4">Description</td>
    </tr>
    <tr> 
    <td colspan="4"><? print "$description"; ?></td>
    </tr>
    <tr> 
    <td colspan="2">Draft</td>
    <td height="21" colspan="2">Current</td>
    </tr>
    <tr> 
    <td colspan="2"><? print "$draft"; ?></td>
    <td colspan="2"><? print "$current"; ?></td>
    </tr>
    </table></td>
    </tr>
    </table> </form>
    </body>
    </html>

  10. #10
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I am assuming you are having the error in the second page? Try this code instead:
    Code:
    <?
    $host="localhost";
    $user="test_user";
    $password="test_pw";
    $dbname="test_db";
    $dbtable="test_table";
    
    $homepage="enternew.php";
    
    $dbh=mysql_connect ("localhost", "test_user", "test_pw") or die ('I cannot connect to the database because: ' . mysql_error());
    mysql_select_db ("test_db");
    ?>
    <html>
    <head>
    <title>site</title>
    </head>
    <body>
    <?
    
    if($hdAction==1)
    {
    
    $sql = "SELECT id, first, last, thumba, thumbb, thumbc, thumbd, team, number, league, year, home, brand, loa, size, description, draft, current FROM $dbtable where id=$id LIMIT $Start, $PerPage";
    $result = mysql_query($sql, $dbh) or die( "Error in <b>$sql</b>. Mysql says". mysql_error() );
    
    }
    else
    {
    $sql = "SELECT id, first, last, thumba, thumbb, thumbc, thumbd, team, number, league, year, home, brand, loa, size, description, draft, current
               FROM $dbtable where id=$id LIMIT $Start, $PerPage";
    $result = mysql_query($sql, $dbh) or die( "Error in <b>$sql</b>. Mysql says". mysql_error() );
    }
    $first = mysql_result($result, 0, "first");
    $last = mysql_result($result, 0, "last");
    $thumba = mysql_result($result, 0, "thumba");
    $thumbb = mysql_result($result, 0, "thumbb");
    $thumbc = mysql_result($result, 0, "thumbc");
    $thumbd = mysql_result($result, 0, "thumbd");
    $team = mysql_result($result, 0, "team");
    $number = mysql_result($result, 0, "number");
    $league = mysql_result($result, 0, "league");
    $year = mysql_result($result, 0, "year");
    $home = mysql_result($result, 0, "home");
    $brand = mysql_result($result, 0, "brand");
    $loa = mysql_result($result, 0, "loa");
    $size = mysql_result($result, 0, "size");
    $description = mysql_result($result, 0, "description");
    $draft = mysql_result($result, 0, "draft");
    $current = mysql_result($result, 0, "current");
    
    ?>
    &nbsp;
    &nbsp;
    <form name="form1" method="post" action="">
    <table width="100%" border="0" cellspacing="10" cellpadding="0">
    <tr> 
    <td valign="top">
    
    <table width="100%" height="30" border="0" cellpadding="0" cellspacing="3">
    <tr> 
    <td><a href="display_jersey.php?hdAction=1&id=<? print mysql_result($result, 0, "id");?>-1">Previous</a></td>
    <td>Home</td>
    <td><a href="display_jersey.php?hdAction=1&id=<? print mysql_result($result, 0, "id");?>%2B1" >Next</a>
    
    <input type="hidden" name="hdAction">
    <input type="hidden" name="Ident"> </td>
    </tr>
    </table></td>
    </tr>
    <tr> 
    <td> <table width="100%">
    <tr> 
    <td colspan="4"><? print "$first"; ?> <? print "$last"; ?></td>
    </tr>
    <tr> 
    <td colspan="4"><table width="100%" border="0" cellspacing="2" cellpadding="0">
    <tr> 
    <td><? print "$thumba"; ?> </td>
    <td><? print "$thumbb"; ?> </td>
    <td><? print "$thumbc"; ?> </td>
    <td><? print "$thumbd"; ?> </td>
    </tr>
    </table></td>
    </tr>
    <tr> 
    <td>Team</td>
    <td>Number</td>
    <td>League</td>
    <td>Year</td>
    </tr>
    <tr> 
    <td><? print "$team"; ?></td>
    <td><? print "$number"; ?></td>
    <td><? print "$league"; ?></td>
    <td> <? print "$year"; ?></td>
    </tr>
    <tr> 
    <td>Home</td>
    <td>Brand</td>
    <td>LOA</td>
    <td>Size</td>
    </tr>
    <tr> 
    <td><? print "$home"; ?></td>
    <td><? print "$brand"; ?></td>
    <td><? print "$loa"; ?></td>
    <td> <? print "$size"; ?></td>
    </tr>
    <tr> 
    <td colspan="4">Description</td>
    </tr>
    <tr> 
    <td colspan="4"><? print "$description"; ?></td>
    </tr>
    <tr> 
    <td colspan="2">Draft</td>
    <td height="21" colspan="2">Current</td>
    </tr>
    <tr> 
    <td colspan="2"><? print "$draft"; ?></td>
    <td colspan="2"><? print "$current"; ?></td>
    </tr>
    </table></td>
    </tr>
    </table> </form>
    </body>
    </html>
    From what I see, it may be a minor syntax error. Try this, if it doesn't work (or gets a new error) post the error message. Are you positive that the respective rows exist, that is an all-too-common "stupid" problem.

  11. #11
    SitePoint Enthusiast jenny28's Avatar
    Join Date
    Dec 2004
    Location
    Seattle
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ugh

    Same thing...does anyone else get frustrated while learning this stuff, or am I taking it too seriously?

    Error in SELECT id, first, last, thumba, thumbb, thumbc, thumbd, team, number, league, year, home, brand, loa, size, description, draft, current FROM test_table where id= LIMIT , . Mysql saysYou have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT ,' at line 1

    I checked all the fields to the database and everything is the same. Same spelling, same usage of caps/lowercase...is there anywhere/thing else I should check?
    Last edited by jenny28; Dec 2, 2004 at 18:26.

  12. #12
    SitePoint Member
    Join Date
    Dec 2004
    Location
    Piura - Perú
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem is that you have not defined the variables $Start and $PerPage so the sql string is incomplete. (See the LIMIT clause).

    I have written a pagination script that is very easy to use and is very popular between the beginners in the spanish comunity.
    It is written in Spanish, but I can help you to adapt it.
    If you are interested in it you can download from:
    [Advisor edit]You are not allowed to link to your own site, even if it is answering the question. -Helge[/Advisor edit]
    See the examples (in spanish):

    And the documentation:

    You can contact me for anything:
    jorpinedo[@]yahoo.es
    Last edited by Helge; Dec 3, 2004 at 11:59. Reason: Removed links
    Paginator 1.5 An easy pagination script. (in spanish)

  13. #13
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    PHP Code:
    <?
    $start 
    == 1
    $perpage 
    == 1

    $host
    ="localhost";
    $user="test_user";
    $password="test_pw";
    $dbname="test_db";
    $dbtable="test_table";

    $homepage="enternew.php";

    $dbh=mysql_connect ("localhost""test_user""test_pw") or die ('I cannot connect to the database because: ' mysql_error());
    mysql_select_db ("test_db");
    ?>
    <html>
    <head>
    <title>site</title>
    </head>
    <body>
    <?

    if($hdAction==1)
    {

    $sql "SELECT id, first, last, thumba, thumbb, thumbc, thumbd, team, number, league, year, home, brand, loa, size, description, draft, current FROM $dbtable where id=$id LIMIT $Start$PerPage";
    $result mysql_query($sql$dbh) or die( "Error in <b>$sql</b>. Mysql says"mysql_error() );

    }
    else
    {
    $sql "SELECT id, first, last, thumba, thumbb, thumbc, thumbd, team, number, league, year, home, brand, loa, size, description, draft, current
               FROM 
    $dbtable where id=$id LIMIT $Start$PerPage";
    $result mysql_query($sql$dbh) or die( "Error in <b>$sql</b>. Mysql says"mysql_error() );
    }
    $first mysql_result($result0"first");
    $last mysql_result($result0"last");
    $thumba mysql_result($result0"thumba");
    $thumbb mysql_result($result0"thumbb");
    $thumbc mysql_result($result0"thumbc");
    $thumbd mysql_result($result0"thumbd");
    $team mysql_result($result0"team");
    $number mysql_result($result0"number");
    $league mysql_result($result0"league");
    $year mysql_result($result0"year");
    $home mysql_result($result0"home");
    $brand mysql_result($result0"brand");
    $loa mysql_result($result0"loa");
    $size mysql_result($result0"size");
    $description mysql_result($result0"description");
    $draft mysql_result($result0"draft");
    $current mysql_result($result0"current");

    ?>
    &nbsp;
    &nbsp;
    <form name="form1" method="post" action="">
    <table width="100%" border="0" cellspacing="10" cellpadding="0">
    <tr> 
    <td valign="top">

    <table width="100%" height="30" border="0" cellpadding="0" cellspacing="3">
    <tr> 
    <td><a href="display_jersey.php?hdAction=1&id=<? print mysql_result($result0"id");?>-1">Previous</a></td>
    <td>Home</td>
    <td><a href="display_jersey.php?hdAction=1&id=<? print mysql_result($result0"id");?>%2B1" >Next</a>

    <input type="hidden" name="hdAction">
    <input type="hidden" name="Ident"> </td>
    </tr>
    </table></td>
    </tr>
    <tr> 
    <td> <table width="100%">
    <tr> 
    <td colspan="4"><? print "$first"?> <? print "$last"?></td>
    </tr>
    <tr> 
    <td colspan="4"><table width="100%" border="0" cellspacing="2" cellpadding="0">
    <tr> 
    <td><? print "$thumba"?> </td>
    <td><? print "$thumbb"?> </td>
    <td><? print "$thumbc"?> </td>
    <td><? print "$thumbd"?> </td>
    </tr>
    </table></td>
    </tr>
    <tr> 
    <td>Team</td>
    <td>Number</td>
    <td>League</td>
    <td>Year</td>
    </tr>
    <tr> 
    <td><? print "$team"?></td>
    <td><? print "$number"?></td>
    <td><? print "$league"?></td>
    <td> <? print "$year"?></td>
    </tr>
    <tr> 
    <td>Home</td>
    <td>Brand</td>
    <td>LOA</td>
    <td>Size</td>
    </tr>
    <tr> 
    <td><? print "$home"?></td>
    <td><? print "$brand"?></td>
    <td><? print "$loa"?></td>
    <td> <? print "$size"?></td>
    </tr>
    <tr> 
    <td colspan="4">Description</td>
    </tr>
    <tr> 
    <td colspan="4"><? print "$description"?></td>
    </tr>
    <tr> 
    <td colspan="2">Draft</td>
    <td height="21" colspan="2">Current</td>
    </tr>
    <tr> 
    <td colspan="2"><? print "$draft"?></td>
    <td colspan="2"><? print "$current"?></td>
    </tr>
    </table></td>
    </tr>
    </table> </form>
    </body>
    </html>

  14. #14
    SitePoint Member
    Join Date
    Dec 2004
    Location
    Piura - Perú
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yor case whith my script:
    PHP Code:
    <?php
    $host
    ="localhost";
    $user="test_user";
    $password="test_pw";
    $dbname="test_db";
    $dbtable="test_table";

    $dbh=mysql_connect ("localhost""test_user""test_pw") or die ('I cannot connect to the database because: ' mysql_error());
    mysql_select_db ("test_db");
    ?>
    <html>
    <head>
    <title>site</title>
    </head>
    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <?
    // String sql (in variable $_pagi_sql. )
    $_pagi_sql "select id, first, last, thumba, thumbb, thumbc, thumbd, team, number, league, year, home, brand, loa, size, description, draft, current from $dbtable where id=$id;";

    // Results per page (optional, default 20)
    $_pagi_cuantos 1

    // Variables that you want to spread (optional, default: all GET array)
    $_pagi_propagar = array("id");

    //Include the pagination script. It includes the mysql_query() automatic
    include("paginator.inc.php");

    // Here is available the variable $_pagi_result
    while($row mysql_fetch_array($_pagi_result)){
    $first $row["first"];
    $last $row["last"];
    $thumba $row["thumba"];
    $thumbb $row["thumbb"];
    $thumbc $row["thumbc"];
    $thumbd $row["thumbd"];
    $team $row["team"];
    $number $row["number"];
    $league $row["league"];
    $year $row["year"];
    $home $row["home"];
    $brand $row["brand"];
    $loa $row["loa"];
    $size $row["size"];
    $description $row["description"];
    $draft $row["draft"];
    $current $row["current"];
    }

    //Include the nav bar
    echo"<p>".$_pagi_navegacion."</p>";
    ?>
    &nbsp;
    &nbsp;
    ...
    ...
    The rest is the same
    Paginator 1.5 An easy pagination script. (in spanish)

  15. #15
    SitePoint Enthusiast jenny28's Avatar
    Join Date
    Dec 2004
    Location
    Seattle
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting closer :)

    I feel like it's almost there...it has to be

    I tried out both scripts. The spanish one asked me for the pagination file that's included in the script, so I tried geniusgoalies script (great name, btw!!). I get the following error upon loading the file:

    Parse error: parse error, unexpected T_VARIABLE in /home/*****/public_html/test_folder/display_jersey.php on line 3

    So, i went and did a search on this forum for that error message and saw a bunch of different results. Some said it was because of the version of PHP they wrote the script with, some said it was because they should be using GET where they were using POST, and on and on and on. I tried a bunch of different things posters had suggested, but continued to get the same result. I'm not really sure if any of those are a factor on this script though, since line 3 is simply "$perpage == 1"

    My geniusgoalie...can you help a girl with this one?

  16. #16
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Erh I'm not geniusgoalie but try this:

    PHP Code:
    $start == 1;
    $perpage == 1
    Note the semi-colons...

  17. #17
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Hi Jenny28,
    I'm not geniusgoalie but I might be able to help, it's a long shot but if you copied GG's code exactly he missed to semicolon's from the lines
    PHP Code:
    $start == 1;
    $perpage == 1
    Try that!

    SpikeZ
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  18. #18
    SitePoint Enthusiast jenny28's Avatar
    Join Date
    Dec 2004
    Location
    Seattle
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks mudshark & spikez! I forgot to mention that one of the tutorials suggested that too, and it returns that same error i was getting before:

    Error in select id,first,last,thumba,thumbb,thumbc,thumbd,team,number,league,year,home,brand,l oa,size,description,draft,current from test_table where id=18 LIMIT ,;. Mysql says You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

    I dreamt all night of PHP codes...they kept running at me and at the last minute, right ebfore they were going to attack, they would die....do you think that means something?
    Glory Lasts Forever.

  19. #19
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Hi jenny,
    first up how freaky myself and mudshark posting the same thing at the same time.....

    Now then try changing ...
    PHP Code:
    where id='$id' LIMIT $Start10"; 
    Sweet dreams!
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  20. #20
    SitePoint Enthusiast jenny28's Avatar
    Join Date
    Dec 2004
    Location
    Seattle
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    hahaha

    I guess great minds think alike!

    Where should I post that code? Does it go under
    $start == 1;
    $perpage == 1;

    or does it replace it?

    Thanks spikez!!!!
    Glory Lasts Forever.

  21. #21
    SitePoint Enthusiast jenny28's Avatar
    Join Date
    Dec 2004
    Location
    Seattle
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    record number?

    Would it matter of the first record in my db is 18? The id column is an autoincremenent and I did a bunch of testing when creating the original entry and display pages, and so I've deleted the first 17 records...would that change the code at all? Could that be my problem (among the other obivous ones *wink*)?
    Glory Lasts Forever.

  22. #22
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Deleting the records won't make a difference so don't worry about that!

    The bit of code I gave you is for the end of the sql statement so it would read.
    PHP Code:
    $sql "SELECT id, first, last, thumba, thumbb, thumbc, thumbd, team, number, league, year, home, brand, loa, size, description, draft, current FROM $dbtable where id='$id' LIMIT $Start, 10"
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  23. #23
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spikeZ
    Deleting the records won't make a difference so don't worry about that!

    The bit of code I gave you is for the end of the sql statement so it would read.
    PHP Code:
    $sql "SELECT id, first, last, thumba, thumbb, thumbc, thumbd, team, number, league, year, home, brand, loa, size, description, draft, current FROM $dbtable where id='$id' LIMIT $Start, 10"
    It's quite interesting that this hasn't been working, it is common and correct syntax. I wonder... do you by chance know what version of php you are running?
    I am confused myself... this seems like it should work!

  24. #24
    SitePoint Enthusiast jenny28's Avatar
    Join Date
    Dec 2004
    Location
    Seattle
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Version

    I am running PHP Version 4.3.7

    Does that help?
    Last edited by jenny28; Dec 4, 2004 at 20:26.
    Glory Lasts Forever.

  25. #25
    SitePoint Enthusiast jenny28's Avatar
    Join Date
    Dec 2004
    Location
    Seattle
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Anyone?

    Does anyone know why my script isn't working???
    Glory Lasts Forever.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •