Php rid variable after go to 2nd page in pagination

I’m using php pagination in my webpage but after go to 2nd page with help of pagination php rid the variable which I REQUEST from the last page, and getting the error like,

Undefined index: title_no in E:\…\page_name.php on line 7

but when I’m using static variable then its working fine, but in dynamic it’s rid the variable after go to 2nd page, This is some code of pagination where I’m getting problem


ob_start();
@session_start();
include("connect.php");
$title_no=@$_REQUEST['title_no'];
$tbl_name="postadd";

$adjacents = 2;
$productQuery = " where visible='1' AND title_no='{$_REQUEST['title_no']}'";

$query = "SELECT COUNT(*) as num FROM $tbl_name $productQuery";
$total_pages_row = mysql_query($query);
$total_pages_num = mysql_fetch_assoc($total_pages_row);
$total_pages = $total_pages_num['num'];

$targetpage = "product_listing_working.php";
$limit_val = @$_GET['pagesize'];
if($limit_val!='') {
    $limit = $limit_val;
} else {
    $limit = 3;
}
$page = @$_GET['page'];
if($page)
    $start = ($page - 1) * $limit;
else
    $start = 0;

$sql = "SELECT * FROM $tbl_name $productQuery LIMIT $start, $limit";
$result = mysql_query($sql);

Please guide me where I’m going wrong
Thanks in advance

What is the source for title_no? Is it coming from a form or a url query string? Your code is wide open to a SQL Injection attack.

Please be aware that the mysql_* extension is now deprecated as of the current version of PHP and will very likely be removed from the next 5.x version and will likely not be in PHP 6.x (when it eventually is released). You should migrate over to either the mysqli_* extension or to PDO. PDO is a better choice as it doesn’t tie you down so much to a particular database server software.

Once you have migrated you should use Prepared Statements to prevent SQL Injection attacks. Have a read of this article from the PHP manual, it shows how to use prepared statements with PDO and also explains the principle.

its coming from url string as like, <a href=“product.php?title_no=<?php $row[‘title_no’]; ?>”>Select </a>