hi;
i am facing this trouble in paginatoin
" Notice: Undefined index: start in F:\wamp\www\Cybertraders\demo_paging1.php on line 16 "

$page_name="demo_paging1.php"; 
$start=$_GET['start'];

the upper line is line 16

if(strlen($start) > 0 and !is_numeric($start)){
echo "Data Error";
exit;
}
Member Avatar for iamthwee

This is saying no GET variable 'start' is NOT being recognised...

Are you passing it?

if (isset($_GET['start'])) {
  $start=$_GET['start'];
}

Read this article to help further.

Brothers this is my code, and i cant know how to fix it.

<?php
//****************************************************************************
////////////////////////Downloaded from  www.plus2net.com   //////////////////////////////////////////
///////////////////////  Visit www.plus2net.com for more such script and codes.
////////                    Read the readme file before using             /////////////////////
//////////////////////// You can distribute this code with the link to www.plus2net.com ///
/////////////////////////  Please don't  remove the link to www.plus2net.com ///
//////////////////////////
//*****************************************************************************
?>

<?php
         // All database details will be included here 

$page_name="Products_.php"; //  If you use this code with a different page ( or file ) name then change this 
$start=$_GET['start'];
if(strlen($start) > 0 and !is_numeric($start)){
echo "Data Error";
exit;
}


$eu = ($start - 0); 
$limit = 5;                                 // No of records to be shown per page.
$this1 = $eu + $limit; 
$back = $eu - $limit; 
$next = $eu + $limit; 

$id=@$_GET['id'];

/////////////// WE have to find out the number of records in our table. We will use this to break the pages///////
$query2=" SELECT * FROM cat_2 WHERE cat_id='$id'  ";
 $coun = 0;
$result2=mysql_query($query2);
echo mysql_error();
$nume=mysql_num_rows($result2);
/////// The variable nume above will store the total number of records in the table////

/////////// Now let us print the table headers ////////////////
echo "<TABLE width=50% align=center  cellpadding=0 cellspacing=0> <tr>";
echo "<td  >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'></font></td>";
echo "<td   >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'></font></td>";
echo "<td  >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'></font></td></tr>";

////////////// Now let us start executing the query with variables $eu and $limit  set at the top of the page///////////
$query=" SELECT * FROM cat_2 WHERE cat_id='$id' limit $eu, $limit ";
$result=mysql_query($query);
echo mysql_error();

//////////////// Now we will display the returned records in side the rows of the table/////////
while($noticia = mysql_fetch_array($result))
{
    {$coun++;
 if ( $coun%5 == 0 ) { ?>
                             <td><div style="padding-left:11px; padding-top:11px; width:130px;">
                             <div class="border_gray" align="center">
                             <a href="#">
                                                             <img src="admin/<?php echo $noticia['cat2_image'];?>" style="width: 120px; height: 150px; display:inline-block; padding-top:5px;" border="0" align="center" />
                                                             </a>
                                                             <div style="padding-top:4px; padding-left:10px; cursor: pointer; color: rgb(110, 101, 110); font-size: 12px; text-decoration: none; text-align:left;">
                                                             <?php echo $noticia['cat2_title'];?>
                                                             </div>
                                                             <div style="padding-top:4px; padding-right:10px; font-size:14px;font-weight:bold;color:#84c05a;" align="right" >Rs.&nbsp;
                                                             <?php echo $noticia['cat2_price'];?>
                                                             </div>
                                                             </div></div>
                                                             </td></tr><tr>   
                                                             <?php } else{ ?>
                                                             <td><div style="padding-left:11px; width:130px; padding-top:11px;">
                                     <div class="border_gray" align="center"><a href="#">

                                                             <img src="admin/<?php echo $noticia['cat2_image'];?>" style="width: 120px; height: 150px; display:inline-block; padding-top:5px;" border="0" /> </a> 

                                                             <div style="padding-top:4px; padding-left:10px; cursor: pointer; color: rgb(110, 101, 110); font-size: 12px; text-decoration: none; text-align:left;">
                                                             <?php echo $noticia['cat2_title'];?>
                                                             </div>
                                                             <div style="padding-top:4px; padding-right:10px; font-size:14px;font-weight:bold;color:#84c05a;" align="right">Rs.&nbsp;
                                                             <?php echo $noticia['cat2_price'];?>
                                                             </div>
                                                             </div></div>   
                                                             </td>

                                                             <?php } }?><?php
////////////////////////////// End of displaying the table with records ////////////////////////

/////////////////////////////// 
if($nume > $limit ){ // Let us display bottom links if sufficient records are there for paging

/////////////// Start the bottom links with Prev and next link with page numbers /////////////////
echo "<table align = 'center' width='50%'><tr><td  align='left' width='30%'>";
//// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
if($back >=0) { 
print "<a href='$page_name?start=$back'><font face='Verdana' size='2'>PREV</font></a>"; 
} 
//////////////// Let us display the page links at  center. We will not display the current page as a link ///////////
echo "</td><td align=center width='30%'>";
$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit){
if($i <> $eu){
echo " <a href='$page_name?start=$i'><font face='Verdana' size='2'>$l</font></a> ";
}
else { echo "<font face='Verdana' size='4' color=red>$l</font>";}        /// Current page is not displayed as link and given font color red
$l=$l+1;
}


echo "</td><td  align='right' width='30%'>";
///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
if($this1 < $nume) { 
print "<a href='$page_name?start=$next'><font face='Verdana' size='2'>NEXT</font></a>";} 
echo "</td></tr></table>";
}
}// end of if checking sufficient records are there to display bottom navigational link. 
?>
<p align='center'><a href=php_paging.php>PHP paging basic tutorial>></a> |
<a href=php_paging2.php>PHP paging tutorial Part II >></a> | <a href=demo_paging1.php>PHP paging demo I >></a> |
<a href=demo_paging2.php>PHP paging customized paging script demo II >></a> |
<br>
<a href='php_paging.zip' target=new>Download the ZIP file here&nbsp; php_paging.php</a> |

<a href=php_paging_adv.php>Demo of advanced php paging</a></p><br>
<center><a href='http://www.plus2net.com'>PHP SQL HTML free tutorials and scripts</a></center> 
Member Avatar for iamthwee

I think you need to post up the php file which is called before this one.

The error msg says it doesn't recognise 'start' so it isn't getting passed into your file above?

Unless the var start is being called from here.

and one more problem is there that it is not displaying the results on second page.

I think you need to post up the php file which is called before this one

dear i can not understand which file you really meant to pass before

add this 3 lines in the beginging of your page

error_reporting(0);
ini_set("display_errors",0);
if ($_GET['start']=="")
    $_GET['start']=1;

Brother this removes the error but still i cant see the results on second page,

whtas on screen now

on page one results are fine
but on second it shows nothing

you must also pass id with start

start=$i&id={$_GET[id]}'

<?php
    error_reporting(0);
    ini_set("display_errors",0);
    if ($_GET['start']=="")
    $_GET['start']=1;
    $start='$i&id={$_GET[id]}';
         // All database details will be included here 
$page_name="Products_.php"; //  If you use this code with a different page ( or file ) name then change this 


$eu = ($start - 0); 
$limit = 5;                                 // No of records to be shown per page.
$this1 = $eu + $limit; 
$back = $eu - $limit; 
$next = $eu + $limit; 

$id=@$_GET['id'];

i have tried it like this, but still the same

<?php  
    error_reporting(0);
    ini_set("display_errors",0);
    if ($_GET['start']=="")
    $_GET['start']=1;
    $start='$i&$id={$_GET[id]}';
         // All database details will be included here 
$page_name="Products_.php"; //  If you use this code with a different page ( or file ) name then change this 
$start=$_GET['start'];
if(strlen($start) > 0 and !is_numeric($start)){
echo "Data Error";
exit;
}

$eu = ($start - 0); 
$limit = 10;                                 // No of records to be shown per page.
$this1 = $eu + $limit; 
$back = $eu - $limit; 
$next = $eu + $limit; 

$id=@$_GET['id'];

Also not working like this

not here man you need to do in first page

print "<a href='$page_name?start=$next&id={$_GET[id]}'><font face='Verdana' size='2'>NEXT</font></a>";

where ever you set $start everywhere you have to add $_GET[id]

thanks all brothers who helped me, this issue is solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.