If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Mysql :Need Help urgently with Next/prev Button

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-22-04, 07:23
envy envy is offline
Registered User
 
Join Date: Mar 2004
Location: dublin
Posts: 5
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>";
}

?>
Reply With Quote
  #2 (permalink)  
Old 03-22-04, 08:43
ika ika is offline
Registered User
 
Join Date: Oct 2003
Location: Slovakia
Posts: 482
Re: Mysql :Need Help urgently with Next/prev Button

Quote:
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On