Forum Moderators: coopster

Message Too Old, No Replies

Big Trouble With Pagination

Pagination Problems

         

djdvine

8:16 am on Apr 4, 2008 (gmt 0)

10+ Year Member



All, I am a newbie to PHP / MYSQL and for 2 months I have been trying to figure out how to paginate my new movie database I created. I have been able to figure it out when I don't have a "SUBMIT" button on a form (to search for certain criteria), but when the user enters a search term and hits "Next" on the hyperlink to go to the next page of results, it comes up blank. I believe the search term isn't carrying over for some reason.
Below is my code, and I have taken off all of the pagination code I had, so I won't confuse anyone. Can someone PLEASE input the correct code in the correct spots so I can paginate the results? (10 items per page will be fine). Thanks in advance, this is KILLING ME!

//BEGIN CODE//
</FORM>
echo"<input type=submit name=submit value=submit>";
echo "</FORM>";

$cast = $_GET['cast'];

if ($_GET['cast'] =="")
{
echo "you did not enter any value in the search box";
exit();
}

//MY SEARCH QUERY//
if($cast != ""){
$query = "SELECT * FROM MAIN WHERE
CAST LIKE \"%$cast%\" ORDER BY TITLE";
$result = mysqli_query($cxn,$query)
or die ("NO YOU IDIOT");
$nrows = mysqli_num_rows($result);

echo "<FONT COLOR=white>Actor Only</FONT></CENTER><br>";
if ($nrows >0){
echo "<center><img src=images/newang.jpg border=1><BR><BR>";
echo "<font size=5><font color=990033>So, You Want To See <font color=151B8D>$cast</font> ? Here Are <font color=151B8D>$nrows</font> of Dave's Movies to Choose From:</center></font><BR>";
echo "<font size=5><font color=white><b><center><a href=\"http://www.imdb.com/find?s=all&q=$cast\" target=_blank>See $cast's Other Movies</a></font></font color></b></center><br>";
}
else
{
echo "<center><img src=images/thebotch.jpg border=2><BR><BR>";
echo "<font size=5><font color=990033>Your Search For <font color=151B8D>$cast</font> Came Up Empty, Try Again...<b>JackAss!</b></center></font><BR>";
}
}

while ($row = mysqli_fetch_assoc($result)){

$movie_id = $row['MOVIE_ID'];
$cover_art= $row['COVER_ART'];
$title= $row['TITLE'];
$genre= $row['GENRE'];
$year= $row['YEAR'];
$length= $row['LENGTH'];
$cast= $row['CAST'];
$review= $row['REVIEW'];
$director= $row['DIRECTOR'];
$director= $row['DIRECTOR'];
$summary= $row['SUMMARY'];

echo "<table>

<tr><td bgcolor=#660033><b><font color=yellow face=\"Georgia Bold\" size=6>$title (<i>$year</i>)</b></font><br><a href=trailers/movie_trailers/$movie_id.html><img align=left src=images/CoverArt/$cover_art border=3 alt=\"$title\"></a>

<b><i><font face=arial color=#99FFFF size=4>$genre Film Directed by $director, and $length Long</i></b></font>

<b>&nbsp;&nbsp;<img src=images/$review.gif><br><br>

<b><font color=white face=arial size=4>SUMMARY:</font><font color=#FFFFCC size=4 face=arial> $summary</font><br><br>
<b><font color=white face=arial size=4>CAST:</font><font color=#FFFFCC size=4 face=arial> $cast</font><br><br>

</td></tr>
<tr><td><hr size=5 align=center width=100% color=#FF3399>

</tr></td></table>";
}

?>

Again, thanks, if you have any questions, please feel free to email me

[edited by: eelixduppy at 6:35 pm (utc) on April 10, 2008]
[edit reason] disabled smileys [/edit]

eelixduppy

6:38 pm on Apr 10, 2008 (gmt 0)



Hello and Welcome to WebmasterWorld!

You were probably getting a blank page because there was a fatal error somewhere in your previous code. I'm sure if you were to look at your error logs you'd find something going wrong in that script. That still doesn't mean that your code and logic was flawless, so to help you along with that aspect, there is a nice thread we have that explains pagination in detail. If you follow that and use it as a template, I'm sure you will get what you want. The reason I am not doing the coding for you is because you will not learn anything that way and you would get stuck in the future again. Give it your best try first, and then when you run into specific problems you can post your questions here again.

Here is that thread I promised: [webmasterworld.com...]

djdvine

6:42 am on Apr 11, 2008 (gmt 0)

10+ Year Member



Thanks, I'll check out this link, and give it a shot.
Thanks!