Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Location
    dublin
    Posts
    5

    Unanswered: Mysql :Need Help urgently with Next/prev Button

    hi i need help with a next button and previous button, im using php to connect to my mysql database..my table appears and the next button works..but then when it reaches the end of the file,the table appears blank..Does anybody know how to do this?? My project is an online video shop, so when the user log's in they can click next to view the next video and previous video etc...anyway heres my code..it's pretty crap but im a beginner!! So if anybody can help me with a next buttton and previous button to move through my database,,it would be greatly appreciated as i'm presenting this assignment tomorrow to my lecturer!!

    <?php
    session_start();
    ?>

    <?php
    $max_cols = 1;
    if(!$start)
    $start = 0;
    echo '<body bgcolor="#000066">';
    $db = mysql_connect("mysql.internal", "blah" "password")
    or die("Couldn't connect to the database.");
    mysql_select_db("envy")
    or die("Couldn't select the database");
    $result = mysql_query("SELECT * FROM GameTitle LIMIT $start,$max_cols",$db);
    //
    $num=mysql_num_rows($result);
    $myrow = mysql_fetch_array($result);

    if ($num!=0)
    {
    echo"<table width=\"95%\" border=\"1\" bordercolor= \"#990000\" height=\"245\">";
    echo"<tr>";
    echo"<td rowspan=\"6\" width=\"30%\">";
    echo"<div align=\"left\">";
    echo"<font color=\"#FFFFFF\">";



    echo"<td width=\"21%\">";
    echo"<font color=\"#FFFFFF\">";
    echo"Title";
    echo"</td>";

    echo"<td width=\"49%\">";
    echo"<font color=\"#FFFFFF\">";

    printf("%s",$myrow["gameName"]);
    echo"</td>";
    echo"</tr>";

    echo"<tr>";
    echo"<td width=\"21%\">";
    echo"<font color=\"#FFFFFF\">";
    echo"Rating";
    echo"</td>";

    echo"<td width=\"49%\">";
    echo"<font color=\"#FFFFFF\">";
    printf("%s",$myrow["gameRating"]);
    echo"</td>";
    echo"</tr>";


    echo"<tr>";
    echo"<td width=\"21%\">";
    echo"<font color=\"#FFFFFF\">";
    echo"Genre";
    echo"</td>";

    echo"<td width=\"49%\">";
    echo"<font color=\"#FFFFFF\">";
    printf("%s",$myrow["gameGenre"]);
    echo"</td>";
    echo"</tr>";


    echo"<tr>";
    echo"<td width=\"20%\">";
    echo"<font color=\"#FFFFFF\">";
    print("<FORM action=\"rent2.php\" method=\"post\">\n");
    echo"<input type = \"hidden\" name = \"gamestitle\" size = 1 maxlength = 20 value = \"$myrow[1]\"></td>";
    echo"<input type = \"hidden\" name = \"price\" size = 1 maxlength = 20 value = \"5.00\"></td>";
    print("<INPUT TYPE=\"submit\" value=\"Rent\">\n");
    print("</FORM>\n");

    echo"</td>";

    echo"<td width=\"49%\">";
    echo"<font color=\"#FFFFFF\">";

    $start = $start + $max_cols; //$start +
    print("<FORM action=\"match2.php\" method=\"post\">\n");
    print("<INPUT TYPE=\"hidden\" name=\"start\" size = 1 value=$start>\n");
    print("<INPUT TYPE=\"submit\" value=\">>Next >>\">\n");
    print("</FORM>\n");
    echo"</td>";
    echo"</tr>";
    }

    ?>

  2. #2
    Join Date
    Oct 2003
    Location
    Slovakia
    Posts
    482

    Re: Mysql :Need Help urgently with Next/prev Button

    Originally posted by envy
    hi i need help with a next button and previous button, im using php to connect to my mysql database..my table appears and the next button works..but then when it reaches the end of the file,the table appears blank..Does anybody know how to do this?? My project is an online video shop, so when the user log's in they can click next to view the next video and previous video etc...anyway heres my code..it's pretty crap but im a beginner!! So if anybody can help me with a next buttton and previous button to move through my database,,it would be greatly appreciated as i'm presenting this assignment tomorrow to my lecturer!!

    <?php
    session_start();
    ?>

    <?php
    $max_cols = 1;
    if(!$start)
    $start = 0;
    echo '<body bgcolor="#000066">';
    $db = mysql_connect("mysql.internal", "blah" "password")
    or die("Couldn't connect to the database.");
    mysql_select_db("envy")
    or die("Couldn't select the database");
    $result = mysql_query("SELECT * FROM GameTitle LIMIT $start,$max_cols",$db);
    //
    $num=mysql_num_rows($result);
    $myrow = mysql_fetch_array($result);

    if ($num!=0)
    {
    echo"<table width=\"95%\" border=\"1\" bordercolor= \"#990000\" height=\"245\">";
    echo"<tr>";
    echo"<td rowspan=\"6\" width=\"30%\">";
    echo"<div align=\"left\">";
    echo"<font color=\"#FFFFFF\">";



    echo"<td width=\"21%\">";
    echo"<font color=\"#FFFFFF\">";
    echo"Title";
    echo"</td>";

    echo"<td width=\"49%\">";
    echo"<font color=\"#FFFFFF\">";

    printf("%s",$myrow["gameName"]);
    echo"</td>";
    echo"</tr>";

    echo"<tr>";
    echo"<td width=\"21%\">";
    echo"<font color=\"#FFFFFF\">";
    echo"Rating";
    echo"</td>";

    echo"<td width=\"49%\">";
    echo"<font color=\"#FFFFFF\">";
    printf("%s",$myrow["gameRating"]);
    echo"</td>";
    echo"</tr>";


    echo"<tr>";
    echo"<td width=\"21%\">";
    echo"<font color=\"#FFFFFF\">";
    echo"Genre";
    echo"</td>";

    echo"<td width=\"49%\">";
    echo"<font color=\"#FFFFFF\">";
    printf("%s",$myrow["gameGenre"]);
    echo"</td>";
    echo"</tr>";


    echo"<tr>";
    echo"<td width=\"20%\">";
    echo"<font color=\"#FFFFFF\">";
    print("<FORM action=\"rent2.php\" method=\"post\">\n");
    echo"<input type = \"hidden\" name = \"gamestitle\" size = 1 maxlength = 20 value = \"$myrow[1]\"></td>";
    echo"<input type = \"hidden\" name = \"price\" size = 1 maxlength = 20 value = \"5.00\"></td>";
    print("<INPUT TYPE=\"submit\" value=\"Rent\">\n");
    print("</FORM>\n");

    echo"</td>";

    echo"<td width=\"49%\">";
    echo"<font color=\"#FFFFFF\">";

    $start = $start + $max_cols; //$start +
    print("<FORM action=\"match2.php\" method=\"post\">\n");
    print("<INPUT TYPE=\"hidden\" name=\"start\" size = 1 value=$start>\n");
    print("<INPUT TYPE=\"submit\" value=\">>Next >>\">\n");
    print("</FORM>\n");
    echo"</td>";
    echo"</tr>";
    }

    ?>
    Hi,

    this is PHP related question so please go to PHP section.

Posting Permissions

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