Need Help! - Photo Gallery

Hi all,

I have been struggling to figure out what went wrong and/or mistake I made with my website practice.

I incorporated the Image Gallery with my website practice and so far most of the function show correct except with viewing a gallery. Once I select the category to see the content then boom it says no image, but actually there is. See the attachment please.

here is my index:

<div id="content">
<div>

<?php  
if (empty($_GET['cat']) ) 
	{ $cat = '/'; } 
		else 
		{ $cat = ($_GET['cat']); }
		
if ( empty($_GET['page']) ) 
	{ $page = 'about'; } 
		else 
			{ $page = preg_replace('/[^a-zA-Z0-9]/', '', $_GET['page']); }
			
if ( file_exists($cat . '/' . $page . '.php') ) 
    { include $cat . '/' . $page . '.php'; }
		else
			{ include 'info/error.inc.php'; }
?>

</div>
</div>

and this is my viewgalery (i rename it to main):

<?php
        include("config.inc.php");
       
        // initialization
        $result_array = array();
        $counter = 0;

//        $cid = (int)($_GET['cid']); // <--commented
//        $pid = (int)($_GET['pid']); // <--commented

// replaced the above codes
if (isset($_GET['cid'])) { $cid = (int)($_GET['cid']); }
if (isset($_GET['pid'])) { $pid = (int)($_GET['pid']); } 
        // Category Listing

        if( empty($cid) && empty($pid) )
        {
                $number_of_categories_in_row = 4;

                $result = mysql_query( "SELECT c.category_id,c.category_name,COUNT(photo_id)
                                                FROM gallery_category as c
                                                LEFT JOIN gallery_photos as p ON p.photo_category = c.category_id
                                                GROUP BY c.category_id" );
                while( $row = mysql_fetch_array( $result ) )
                {
                        $result_array[] = "<a href='index.php?cat=spgallery&page=main&cid=".$row[0]."'>".$row[1]."</a> "."(".$row[2].")";
						}
                mysql_free_result( $result );        

                $result_final = "<tr>\
";

                foreach($result_array as $category_link)
                {
                        if($counter == $number_of_categories_in_row)
                        {        
                                $counter = 1;
                                $result_final .= "\
</tr>\
<tr>\
";
                        }
                        else
                        $counter++;

                        $result_final .= "\	<td>".$category_link."</td>\
";
                }

                if($counter)
                {
                        if($number_of_categories_in_row-$counter)
                                               $result_final .= "</tr>";
                }
        }


        // Thumbnail Listing

        else if( $cid && empty( $pid ) )
        {
                $number_of_thumbs_in_row = 4;

                // If current page number, use it
                // if not, set one!

                if(!isset($_GET['page'])){
                    $page = 1;
                } else {
                    $page = $_GET['page'];
                }

                // Define the number of results per page
                $max_results = 8;

                // Figure out the limit for the query based
                // on the current page number.
                $from = (($page * $max_results) - $max_results);

                $result = @mysql_query( "SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."' LIMIT $from, $max_results");

                $nr = @mysql_num_rows( $result );

                if( empty( $nr ) )
                {
                    $result_final = "\	<tr><td><div align=\\"center\\"><strong>No images in category found!</strong>
                    <br><br><font size=\\"2\\"><a href='index.php?cat=spgallery&page=main'>Back to Photo Gallery Category List</a></font>
                    </div></td></tr>\
";

                }
                else
                {
                        while( $row = mysql_fetch_array( $result ) )
                        {
                                $result_array[] = "<a href='index.php?cat=spgallery&page=main&cid=$cid&pid=".$row[0]."'><img src='".$images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' /></a>";
						
                        }
                        mysql_free_result( $result );

                        $result = @mysql_query( "SELECT category_name FROM gallery_category WHERE category_id='".addslashes($cid)."'" );
                        list($category_name) = mysql_fetch_array( $result );
                        mysql_free_result( $result );

                         $result_final = "<tr><a href='index.php?cat=spgallery&page=main'>Categories</a> > $category_name<br><br>";
        
                        foreach($result_array as $thumbnail_link)
                        {
                                if($counter == $number_of_thumbs_in_row)
                                {        
                                        $counter = 1;
                                        $result_final .= $category_link."\
</tr>\
<tr>\
";
                                }
                                else
                                $counter++;

                                $result_final .= "\	<td><div align=\\"center\\">".$thumbnail_link."</div></td>\
";
                        }
        
                        if($counter)
                        {
                                if($number_of_photos_in_row)
                        $result_final .= "\	<td colspan='".($number_of_thumbs_in_row)."'></td>\
";
                        $result_final .= "</tr>\
";
                        // Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM gallery_photos WHERE photo_category=".addslashes($cid).""),0);

// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);

if ($total_pages >1)
{  // build links if more than one page


// Build Page Number Hyperlinks
$result_final .=  "<tr><td colspan='".$number_of_thumbs_in_row."'>Showing Page: ".$page.' of '.$total_pages."<br>";


// Build Previous Link
if($page > 1){
    $prev = ($page - 1);
    $result_final .=  "\
<a href=\\"".$_SERVER['PHP_SELF']."?cat=spgallery&page=main&cid=$cid&page=$prev\\" title='Previous Page'><< Prev</a>";
}

for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
        $result_final .= "&nbsp;[$i]";
        } else {
            $result_final .=  "\
<a href=\\"".$_SERVER['PHP_SELF']."?cat=spgallery&page=main&cid=$cid&page=$i\\" title='Page ".$i."'>$i</a>";
    }
}

// Build Next Link
if($page < $total_pages){
    $next = ($page + 1);
    $result_final .=  "\
<a href=\\"".$_SERVER['PHP_SELF']."?cat=spgallery&page=main&cid=$cid&page=$next\\" title='Next Page'>Next >></a>";
}
$result_final .=  "\
</td></tr>";

}
else
{
$result_final .=  "\
";
}
}
}
}

        // Full Size View of Photo
        else if( $pid )
        {
                $result = mysql_query( "SELECT photo_caption,photo_filename FROM gallery_photos WHERE photo_id='".addslashes($pid)."'" );
                list($photo_caption, $photo_filename) = mysql_fetch_array( $result );
                $nr = mysql_num_rows( $result );
                mysql_free_result( $result );        

                if( empty( $nr ) )
                {
                        $result_final = "\	<tr><td>No Photo found</td></tr>\
";
                }
                else
                {
                        $result = mysql_query( "SELECT category_name FROM gallery_category WHERE category_id='".addslashes($cid)."'" );
                        list($category_name) = mysql_fetch_array( $result );
                        mysql_free_result( $result );        

                        $result_final .= "<tr>\
\	<td>
                                                <a href='index.php?cat=spgallery&page=main'>Categories</a> >
                                                <a href='index.php?cat=spgallery&page=main&cid=$cid'>$category_name (Thumbnail Listing)</a></td>\
</tr>\
";

                        $result_final .= "<tr>\
\	<td align='center'>
                                        <br />
                                        <img src='".$images_dir."/".$photo_filename."' border='0' alt='".$photo_caption."' />
                                        <br />
                                        $photo_caption
                                        </td>
                                        </tr>";
                }
        }

// Final Output
echo <<<__HTML_END

<h2>Gallery View</h2>

<table width='40%' cellspacing='3' cellpadding='3' border='1' bordercolor='black' align='center'>
$result_final                
</table>
__HTML_END;
?>

Thanks in advance for help.

It looks like your query is not working properly because you may be getting 0 results…

I’m referring to this query

 $result = @mysql_query( "SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."' LIMIT $from, $max_results");

I don’t think it has anything to do with the addslashes function because I don’t think that you have any special character that needs to be escaped on the variable $cid. I suspect is a number.

You should remove the @ symbol at the beginning so you can get more information about the error.

Thanks for quick reply, I will try.
Will comeback to you later.

thanks again

What I do is add some echo statements to confirm the variable contains what you expect.


echo "cid = $cid <br>";
echo "pid = $pid <br>";

Hi Molona ang Rubble,

I did what both of you suggested, removing @ symbol does not produce more error message.

See the attachment.

Any ideas?

Thanks,

Bong

PS: I tried to run the original without adding it to web template, it does work perfectly without any single error, it something to do with this “$_GET” page function, with my little knowledge with php programing I just can’t figured it out

You get that message because of this code

 

$result = @mysql_query( "SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."' LIMIT $from, $max_results");


$nr = @mysql_num_rows( $result );



                if( empty( $nr ) )

                {

                    $result_final = "\	<tr><td><div align=\\"center\\"><strong>No images in category found!</strong>

                    <br><br><font size=\\"2\\"><a href='index.php?cat=spgallery&page=main'>Back to Photo Gallery Category List</a></font>

                    </div></td></tr>\
";



                }

For some reason, the variable $nr is empty. Your chances are that the query may get no results, and that’s either because one of the names of the fields is misspelled, the query is not right, or the variables that are involved with that query don’t have the expected values.

It looks like the query is correct and, of course I can’t know this, but it doesn’t look like the name of the fields or table are misspelled.

I would echo all the variables involved to make sure that they do have the values I expect… As an example, if I’m on page 1, I would expect $from to be 0.

You can also add a line right under the query, before the variable $nr,

if (!$result) {
    die('Invalid query: ' . mysql_error());

to make sure that you do have a result and see what happens.

Hi Molona,

I will try to insert the above code and see what happen, will come back to you soon.

Thanks and best regards,

Bong

Hi again,

After playing with the codes, I found out by commenting out some lines, the code works, see below what I have done.

        else if( $cid && empty( $pid ) )
        {
                $number_of_thumbs_in_row = 4;
				
                // If current page number, use it
                // if not, set one!
				[COLOR="Blue"]/*
                if(!isset($_GET['page'])){
                    $page = 1;
                } else {
                    $page = $_GET['page'];
                }
				*/[/COLOR]
                // Define the number of results per page
[COLOR="Blue"]/*                $max_results = 8;
                // Figure out the limit for the query based
                // on the current page number.
                $from = (($page * $max_results) - $max_results); */[/COLOR]
                $result = mysql_query( "SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."'"); 
				[COLOR="Blue"]/* LIMIT $from, $max_results"); */[/COLOR]
                
				$nr = mysql_num_rows( $result );
				if( empty( $nr ) )
                {

Texts in blue color are commented out. And the codes works, but I don’t know if it will create some sort of drawback.

What do you think?

Regards,

Bong

Then your problem lies on the LIMIT clause which depends on the variables $from and $max_results.

$max_results is a constant so that shouldn’t be a problem. It is more likely that your problem is $from… which depends on $page.

What I would do is to try the query using numbers instead of variables and remove the comment on the LIMIT line. Let’s say that I would substitute $from with 0 and $max_results with 8.

I would also execute the code echoing the variables $page and $from so I can see the values on screen. If any of those variables gives an unexpected result, that’s where your problem is.

Nice, I will try again with your suggestion, now I can see that we are going somewhere.

thanks again,

best regards,

Bong

Hi molona,

I tried to use the echo thing and these what it shows:

No images in category found!

Back to Photo Gallery Category List

cid = 2
pid =
max_results = 8
from = -8
page = main
result = 

Compare with the original sample the result should be as follows:

cid = 2
pid = 0
max_results = 8
from = 0
page = 1
result = Resource id #7 

Now, I removed the comments and did as follows:

[COLOR="Red"]//				$from = (($page * $max_results) - $max_results);[/COLOR] 
						
                $result = mysql_query( "SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."' LIMIT [COLOR="Red"]0[/COLOR], $max_results"); 
                

Texts in red color are the changes I made and it works again and these are the echos:

cid = 2
pid =
max_results = 8
from =
page = main
result = Resource id #13 

What would be the odd?

Thanks and best regards,

Bong

The odd thing is that $page is equal to ‘main’

Here is the code currently being used to calculate $from

$from = (($page * $max_results) - $max_results); 

That’s functionally identical to the following, which might be easier to understand:

$from = $max_results * ($page - 1);

The purpose of the above code is to work out where to start the listing from.

The value in $page must be a positive numeric number. When $page contains ‘main’, that’s converted to a value of TRUE, which in PHP equates to -1

$page must be a positive numeric number, so where is $page coming from?
Here’s where $page comes from:


if(!isset($_GET['page'])){ 
    $page = 1; 
} else { 
    $page = $_GET['page']; 
} 

I suggest an update to this code, to help ensure that numeric numbers are assigned to $page


$page = 1;
if (isset($_GET['page'])) {
    $page = intval($_GET['page']);
} 

How is $page getting an inappropriate value in the first place?

Because of this:

<a href='index.php?cat=spgallery&page=main'>Back to Photo Gallery Category List</a>

The page value must be a positive numeric number. Using “main” there is a guarantee of failure. Either replace main with 1, or remove the argument completely


<a href='index.php?cat=spgallery&page=1'>Back to Photo Gallery Category List</a>

pmw57 is right.

As you can see if you get no results in the category is because $from is equal to -8. You can’t have a negative value there. The query doesn’t execute and therefore $nr doesn’t exist… and that gives you the message.

If $page is always a positive value (>=1) then you wouldn’t have this problem.

Dear pmw57 and molona,

Thanks a lot for the feedback.

Let me try to explain the website practice the way I understand it and please correct me If I am wrong.

The look of the website practice Home page see attached pic. And the php code here below:

INDEX.PHP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<meta name="Description" content="Information architecture, Web Design, Web Standards." />
<meta name="Keywords" content="your, keywords" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Distribution" content="Global" />
<meta name="Author" content="Erwin Aligam - ealigam@gmail.com" />
<meta name="Robots" content="index,follow" />

<link rel="stylesheet" href="stylez/stylerz.css" type="text/css" />
<?php include('counterz/counter.php'); ?>
<?php include('variablez/variaz.php'); ?>

<title><?php echo $title ?></title>

</head>

<body>

<!-- wrap starts here -->
<div id="wrap">

<?php include('includez/headerz.php'); ?>
<?php include('includez/menuz.php'); ?>			

	<!-- content-wrap starts here -->
	<div id="content-wrap"><div id="content">				
		
		<!-- sidebar starts here -->
<?php include('includez/sideb.php'); ?>
	
		<!-- main starts here -->
		<div id="main">		
		

[COLOR="Green"]			
<?php
	if (empty($_GET['cat']) ) 
	{ $cat = 'pagez'; } 
		else 
		{ $cat = ($_GET['cat']); }
			if ( empty($_GET['page']) ) 
			{ $page = 'home'; } 
				else 
				{ $page = preg_replace('/[^a-zA-Z0-9]/', '', $_GET['page']); }
					if ( file_exists($cat . '/' . $page . '.php') ) 
					{ include ($cat . '/' . $page . '.php'); }
						else
						{ include ('pagez/error.inc.php'); }
			?>[/COLOR]
		
			
							
		<!-- main ends here -->								
		</div>				
				
	<!-- content-wrap ends here -->		
	</div></div>

<?php include('includez/footerz.php'); ?>
	
<!-- wrap ends here -->
</div>

</body>
</html>

Texts in green are codes to fetch the page to go inside the <div id=“main”>.

Now the photo gallery (main.php) will be called by clicking the link at the sidebar which I coded this way:

<li><a href="index.php?cat=pgalz&page=main">The Gallery</a></li>

Inside "index.php the operation of main.php (<– Photo Gallery) goes.

You point out :

How is $page getting an inappropriate value in the first place?

Because of this:
Code:


<a href=‘index.php?cat=spgallery&page=main’>Back to Photo Gallery Category List</a>



What I understand is the above only shows if error occurs, so that I can click on it to go back to main.php. Hope I am correct. See attached pic.

I followed what you have suggested:

$page = 1;
if (isset($_GET['page'])) {
    $page = intval($_GET['page']);
}

The result is the same, see attached pic.

Hope these clear the problem a bit more.

Thanks a million for your time and hoping you have more patient to help me figure this out.

Best regards,

Bong

The problem is that the page part is not allowed to bear any relation to your main.php page. The purpose of the page value is used by your pagination to determine where to list the page from when you navigate using “prev” and “next”, whether that be the 3rd page, the 7th page, or the 1st page.

If you want to use the page value for some other purpose, then that purpose is incompatible with your pagination code.

The page value must be a positive numeric number. If it is not then your pagination is guaranteed to fail. You need to use a different key for the page thatr you want to include, such as section

Solution: Take out that main value, and use a positive numeric value instead. 1 for the first page of results, 2 for the second page of results, 4 for the third page of results, and so forth.

<li><a href="index.php?cat=pgalz&section=main">The Gallery</a></li>

Then update your code to refer to section for the main page part.

The page part must be reserved exclusively for the use of the pagination code. Nothing else.

Hi again,

Thanks very much for the hint.

After looking and reading info about pagination and get value, then do the trial and error thing. Boom, I finally got it working fine, just see below:

<?php
        include('configz/config.inc.php');
        
        // initialization
        $result_array = array();
        $counter = 0;

		if (isset($_GET['cid'])) { $cid = (int)($_GET['cid']); }
		if (isset($_GET['pid'])) { $pid = (int)($_GET['pid']); } 

        // Category Listing

        if( empty($cid) && empty($pid) )
        {
                $number_of_categories_in_row = 4;
                $result = mysql_query( "SELECT c.category_id,c.category_name,COUNT(photo_id)
                                                FROM gallery_category as c
                                                LEFT JOIN gallery_photos as p ON p.photo_category = c.category_id
                                                GROUP BY c.category_id" );
                while( $row = mysql_fetch_array( $result ) )
                {
                        $result_array[] = "<a href='index.php?cat=pgalz&page=main&cid=".$row[0]."'>".$row[1]."</a> "."(".$row[2].")";
                }
                mysql_free_result( $result );        
                $result_final = "<tr>\
";
                foreach($result_array as $category_link)
                {
                        if($counter == $number_of_categories_in_row)
                        {        
                                $counter = 1;
                                $result_final .= "\
</tr>\
<tr>\
";
                        }
                        else
                        $counter++;
                        $result_final .= "\	<th>".$category_link."</th>\
";
                }
                if($counter)
                {
                        if($number_of_categories_in_row-$counter)
							$result_final .= "\	<td colspan='".($number_of_categories_in_row-$counter)."'>&nbsp;</td>\
";
                            $result_final .= "</tr>";
                }
        }
        // Thumbnail Listing
        else if( $cid && empty( $pid ) )
        {
                $number_of_thumbs_in_row = 3;
				
                // If current page number then use it, if not, set one!

[COLOR="SeaGreen"]					if (isset($_GET['pagi'])) { $pagi = (int)($_GET['pagi']); } 
					$pagi = 1;
					if (isset($_GET['pagi'])) 
						{ $pagi = intval($_GET['pagi']); }[/COLOR]

				// Define the number of results per page
				$max_results = 3;
				
				// Figure out the limit for the query based on the current page number.
[COLOR="SeaGreen"]				$from = $max_results * ($pagi - 1);[/COLOR]
						
                $result = mysql_query( "SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."' LIMIT $from, $max_results"); 
                
				$nr = mysql_num_rows( $result );
				if( empty( $nr ) )
                {
                        $result_final = "\	<tr><td><div align=\\"center\\"><strong>No images in category found!</strong>
						<br><br><font size=\\"2\\"><a href='index.php?cat=pgalz&page=main'>Back to Photo Gallery Category List</a></font>
						</div></td></tr>\
";
                }
                else
                {
                        while( $row = mysql_fetch_array( $result ) )
                        {
                                $result_array[] = "<a href='index.php?cat=pgalz&page=main&cid=$cid&pid=".$row[0]."'><img src='".$images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' /></a>";
                        }
                        mysql_free_result( $result );
                        $result = @mysql_query( "SELECT category_name FROM gallery_category WHERE category_id='".addslashes($cid)."'" );
                        list($category_name) = mysql_fetch_array( $result );
                        mysql_free_result( $result );
                         $result_final = "<tr><th class=\\"first\\" colspan='".($number_of_thumbs_in_row)."'><a href='index.php?cat=pgalz&page=main'>Categories</a> > $category_name</th><tr></tr>";
                        foreach($result_array as $thumbnail_link)
                        {
                                if($counter == $number_of_thumbs_in_row)
                                {        
                                        $counter = 1;
                                        $result_final .= $category_link."\
</tr>\
<tr>\
";
                                }
                                else
                                $counter++;
                                $result_final .= "\	<td align=\\"center\\">".$thumbnail_link."</td>\
";
                        }
                        if($counter)
                        {
                                if($number_of_photos_in_row)
                        $result_final .= "\	<td colspan='".($number_of_thumbs_in_row)."'></td>\
";
                        $result_final .= "</tr>\
";
					
// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM gallery_photos WHERE photo_category=".addslashes($cid).""),0);

// Figure out the total number of pages. Always round up using ceil()
 $total_pages = ceil($total_results / $max_results); 

// build links if more than one page 
if ($total_pages >1){  

[COLOR="SeaGreen"]// Build Page Number Hyperlinks
$result_final .=  "<tr><td colspan='".$number_of_thumbs_in_row."'>Showing Page: ".$pagi.' of '.$total_pages."<br>";

// Build Previous Link
if($pagi > 1){
    $prev = ($pagi - 1);
    $result_final .=  "\
<a href=\\"".$_SERVER['REQUEST_URI']."&pagi=$prev\\" title='Previous Page'><< Prev</a>";
}
for($i = 1; $i <= $total_pages; $i++){
    if(($pagi) == $i){
        $result_final .= "&nbsp;[$i]";
        } else {
            $result_final .=  "\
<a href=\\"".$_SERVER['REQUEST_URI']."&pagi=$i\\" title='Page ".$i."'>$i</a>";
    }
}

// Build Next Link
if($pagi < $total_pages){
    $next = ($pagi + 1);
    $result_final .=  "\
<a href=\\"".$_SERVER['REQUEST_URI']."&pagi=$next\\" title='Next Page'>Next >></a>";
}[/COLOR]
$result_final .=  "\
</td></tr>";
}
else
{
$result_final .=  "\
";
} 
} 
}
}
        // Full Size View of Photo
        else if( $pid )
        {
                $result = mysql_query( "SELECT photo_caption,photo_filename FROM gallery_photos WHERE photo_id='".addslashes($pid)."'" );
                list($photo_caption, $photo_filename) = mysql_fetch_array( $result );
                $nr = mysql_num_rows( $result );
                mysql_free_result( $result );        
                if( empty( $nr ) )
                {
                        $result_final = "\	<tr><td>No Photo found</td></tr>\
";
                }
                else
                {
                        $result = mysql_query( "SELECT category_name FROM gallery_category WHERE category_id='".addslashes($cid)."'" );
                        list($category_name) = mysql_fetch_array( $result );
                        mysql_free_result( $result );        
                        $result_final .= "<tr>\
\	<th>
                                                <a href='index.php?cat=pgalz&page=main'>Categories</a> >
                                                <a href='index.php?cat=pgalz&page=main&cid=$cid'>$category_name (Thumbnail Listing)</a></th>\
</tr>\
";
                        $result_final .= "<tr class='row-a'>\
\	<td align='center'>
                                        <br />
                                        <img src='".$images_dir."/".$photo_filename."' border='0' alt='".$photo_caption."' />
                                        <br />
                                        $photo_caption
                                        </td>
                                        </tr>";
                }
        }

		
// Final Output

echo <<<__HTML_END

<table>
$result_final                
</table>
<p>
cid = $cid <br>
pid = $pid <br>
max_results = $max_results <br>
from = $from <br>
page = $page <br>
result = $result <br>
SERVER = $_SERVER <br>
PHP_SELF = $PHP_SELF <br>
request_url = $REQUEST_URl <br>
pagi = $pagi <br>
</p>

__HTML_END;

?>

Texts in green color where I have made some changes. Since page for pagination is virtual (not actual file) I have change “page” to “pagi” for this main.php only.

Plus have to change the following:

<a href=\\"".$_SERVER['PHP_SELF']."?cid=$cid&page=

to this:

<a href=\\"".$_SERVER['REQUEST_URI']."&pagi=

After that it works like a charm.

Hope I did it right but hey it works, just see attached pics.

What is your feedback? I want to know. :slight_smile:

Thanks again and best regards,

Bong

PS: I am learning more and more and it feels good. :slight_smile: