Jump to content

Recommended Posts

This is what i display in an iframe from my index.html

But it's just a display with no links..

 

[hr]<html>
<body>
<?php
 $bpp;		//Books Per Page
 $apt;		//Active page top
 $ppt;		//Previous page top
 $a;		//will be used to print the starting row number that is shown in the page
 $b; 		//will be used to print the ending row number that is shown in the page
/////////////////////////////////////////////////////////////////////////////////
//Database connection
/////////////////////////////////////////////////////////////////////////////////
$user="root";
$password="****";
$database="books";
$tablename="tbl_product";
$conn=mysql_connect("localhost",$user,$password);

mysql_select_db($database) or die( "Unable to select database");
mysql_query($sql,$conn);
$sql= "Select * from $tablename where cat_id='2'";
    	
    	// return result of query to variable
    	$result = mysql_query($sql);




//Check for first load starting row should be 0.
/////////////////////////////////////////////////////////////////////////////////	
if(empty($_GET["apt"])) 
{
	$apt = "0";
} 
else
{
	$apt = $_GET["apt"];
}
/////////////////////////////////////////////////////////////////////////////////

$at = $apt+1; 

$bpp = "50";

$ppt = $apt - $bpp; //Calculating the starting row number for previous page

/////////////////////////////////////////////////////////////////////////////////
//Check if we need Previous link enabled, if on the next set then it will carry the $ppt in its link and enable the link
if ($apt <> 0)
{
	$prv =  "<a href='fiction.php?apt=$ppt'>Previous</a>";
}
else	
{
	$prv =  "<font color='cccccc'>Previous</font>";
}
/////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////
// calculate total number of rows found by the query excluding the limit function added at the end of the SQL statement 

$q="Select SQL_CALC_FOUND_ROWS * from tbl_product where cat_id='2' limit $apt, $bpp";
$rs=mysql_query($q) or die(mysql_error());
$nr = mysql_num_rows($rs); //Number of rows found with LIMIT in action
   
   //FOUND_ROWS   function which actually gives out the number of rows found.

$q0="Select FOUND_ROWS()";
$rs0=mysql_query($q0) or die(mysql_error());
$row0=mysql_fetch_array($rs0);
$nr0 = $row0["FOUND_ROWS()"]; //Number of rows with no limitation



//Check if we reached the end 

if (($nr0 < 10) || ($nr < 10))
{
   		$b = $nr0;
}
else
{
	$b = ($apt) + $bpp;
}
/////////////////////////////////////////////////////////////////////////////////

?>
<!--Create the table and decorate it -->
<br>
<table border="1" cellpadding="4" cellspacing="1" width="95%" align="center">
  
  <tr><td bgcolor="#000080" align='Center'><b><font face="verdana" color="#FFFFFF">Title</font></b></td>
  <td bgcolor="#000080" align='Center'><b><font face="verdana" color="#FFFFFF">test</font></b></td>
</tr>
<?php
while ($row=mysql_fetch_array($rs))
{

	//Start displaying results from DB  and increment so that we can get the next page' when it exits the while            //loop after fullfilling the above SQL criteria.
	/////////////////////////////////////////////////////////////////////////////////
	$apt = $apt +1; 

	$val=$row["pd_name"];  //fields to show 
	$val2=$row ["pd_price"];
	echo "<tr><td width='10%' align='center'><font face=verdana><img src='images/fiction.png' ></font></td><td align='center'><font fave=verdana>$val $val2 £</font></td></tr>";  

}

echo "<tr><td align='right' colspan=2>$prv";


//Check whether there is a Next link if not disable

if ($apt == $nr0)
{ 	
	echo "  |  <font color='CCCCCC'>Next</font>";
}
else
{
	if ($nr0 > 5)
	{ 
		echo "  |  <a href='fiction.php?apt=$apt&ppt=$ppt'>Next  </a>"; 
	}
}


?>
</td>
</tr>
</table>
</body>
</html>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.