I have built a site completely off of tutorials. aonentertainment.com in the pursuit of learning and profit to pay for classes. I want to add (Next,1,2,3,Previous) so I do not have to manually create new pages.
I searched DaniWeb.com and found >> Clean Previous Next Script for MySQL. Link to it.
http://www.daniweb.com/web-development/php/threads/1720
I keep getting this error.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\inetpub\vhosts\aonentertainment.com\httpdocs\paging1.inc.php on line 25
Pages:(1) [1]
Link to where I get the error.
http://aonentertainment.com/index.php?content=inthemix-main
What am I doing wrong?
Table = inthemix
Table items =
inthemixid
title
details
vidcode
shortdesc
thumb
brief
<?php
$server = "private";
$user = "private";
$pass = "private";
$databasename = "databasetest1";
$db = mysql_connect($server, $user, $pass);
mysql_select_db($databasename,$db);
$sql = "SELECT * from inthemix WHERE inthemixid = $inthemixid ORDER by inthemixid desc
limit 0,2";
$query = mysql_query($sql,$db);
$total_results = mysql_num_rows($query);
$limit = "4"; //limit of archived results per page.
$total_pages = ceil($total_results / $limit); //total number of pages
if (empty($page))
{
$page = "1"; //default page if none is selected
}
$offset = ($page - 1) * $limit; //starting number for displaying results out of DB
$query = "SELECT * FROM inthemix WHERE inthemixid = $inthemixid ORDER BY desc LIMIT $offset, $limit";
$result = mysql_query($query);
//This is the start of the normal results...
while($row=mysql_fetch_array($result, MYSQL_ASSOC))
{
$inthemixid = $row['inthemixid'];
$thumb= $row['thumb'];
$title = $row['title'];
$brief = $row['brief'];
$shortdesc = $row['shortdesc'];
echo "<a href=\"index.php?content=inthemix-show-all&id=$inthemixid\"><img src='$thumb' width='127' height='80' border='0' align='left' hspace='9' title='$title' alt='$title' /></a>";
echo"<a href=\"index.php?content=inthemix-show-all&id=$inthemixid\"><b><center>$title</center></B></a><br>\n";
echo"$brief\n";
echo"$shortdesc<br><br>\n";
echo"<hr></hr>";
}
mysql_close();
// This is the Previous/Next Navigation
echo "<font face=Verdana size=1>";
echo "Pages:($total_pages) "; // total pages
if ($page != 1)
{
echo "<a href=$PHP_SELF?page=1><< First</a> "; // First Page Link
$prevpage = $page - 1;
echo " <a href=$PHP_SELF?page=$prevpage><<</a> "; // <strong class="highlight">Previous</strong> Page Link
}
if ($page == $total_pages)
{
$to = $total_pages;
}
elseif ($page == $total_pages-1)
{
$to = $page+1;
}
elseif ($page == $total_pages-2)
{
$to = $page+2;
}
else
{
$to = $page+3;
}
if ($page == 1 || $page == 2 || $page == 3)
{
$from = 1;
}
else
{
$from = $page-3;
}
for ($i = $from; $i <= $to; $i++)
{
if ($i == $total_results) $to=$total_results;
if ($i != $page)
{
echo "<a href=$PHP_SELF?showold=yes&page=$i>$i</a>";
}
else
{
echo "<b><font face=Verdana size=2>[$i]</font></b>";
}
if ($i != $total_pages)
echo " ";
}
if ($page != $total_pages)
{
$nextpage = $page + 1;
echo " <a href=$PHP_SELF?page=$nextpage>>></a> "; // <strong class="highlight">Next</strong> Page Link
echo " <a href=$PHP_SELF?page=$total_pages>Last >></a>"; // Last Page Link
}
echo "</font>";
// This is the end of the Previous/Next Navigation
?>