Jump to content

$_GET


justAnoob

Recommended Posts

And then here is how it is used

 

<a href='$targetpage?page=$counter'  .........etc.......

 

Still having problems with this though

 

$targetpage = 'category.php?selecting=' . $_GET["selecting"] . '&';

 

You must use:

<a href="$targetpage" . "page=$counter"

Link to comment
https://forums.phpfreaks.com/topic/187003-_get/page/2/#findComment-987552
Share on other sites

<a href="$targetpage" . "page=$counter"

 

shouldn't it be

 

<a href="$targetpage" . "?page=$counter"

 

Nope, because the result query will be: category.php?selecting=Video Games&?page=1

 

Notice the extra '?' The top code will be correct to add the extra argument.

Link to comment
https://forums.phpfreaks.com/topic/187003-_get/page/2/#findComment-987557
Share on other sites

Still having problems after a long morning of trying to figure this out.

I know the pagination script works great. I tried it out on a separate page and everything is fine.

But as for below, it seems like it should be working but it is not. Even the url changes when I click on a page number

 

http://www.mysite.com/testing3.php?selecting=Video Games&?page=2

http://www.mysite.com/testing3.php?selecting=Video Games&?page=4

 

But the undefined index error remains and my table continues to show the record.  Any ideas?

 

<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
include 'connection.php';
session_start();
$paginate = '';
$selecting = $_GET['selecting'];
$targetpage = 'testing3.php?selecting=' . $_GET["selecting"] . '&';
// THE CATEGORY COULD BE DIFFERENT, SO MY TARGET PAGE NEEDS TO LOOK SOMETHING LIKE ABOVE.?.
$limit = 1; 
$query = "SELECT id FROM my_table WHERE category = '$selecting' ";
$result = mysql_query($query);
$total_pages =  mysql_num_rows($result);

$page = mysql_escape_string($_GET['page']);    // ERROR ON THIS LINE,   UNDEFINED INDEX PAGE ?
if($page)
{
$start = ($page - 1) * $limit;
}
else
{
$start = 0;
}	
$query2 = "SELECT id, thumb_1 FROM my_table WHERE category = '$selecting' LIMIT $start, $limit";
$result2 = mysql_query($query2); 

if ($page == 0)
{
$page = 1;
}
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total_pages/$limit);
$LastPagem1 = $lastpage - 1;

if ($lastpage < 7 + ($stages * 2))
{
	for ($counter = 1; $counter <= $lastpage; $counter++)
	{
		if ($counter == $page)
		{
			$paginate.= "<span class='inactive_pages'> $counter </span>";
		}
		else
		{
			$paginate.= "<a href='$targetpage?page=$counter' class='active_pages' > $counter </a>";
		}
	}
}

////////////////////   ETC. REST OF THE PAGINATION

echo "<table border='0' CELLPADDING=5 STYLE='font-size:16px' width='750'>";
while ($row = mysql_fetch_array($result2))
{ 
echo "<tr><td align='center'>";
echo '<a href="viewitem.php?sendto='.$row['id'].'"><img src="' . $row['thumb_1'] . '" width="90" border="0" alt=""></a>';
echo "</td></tr>";
    echo '<tr><td height="19" colspan="4">';
    echo '<hr width="550">';
    echo "</td></tr>";
    
}
echo "</table>";
echo $paginate;
?>

Link to comment
https://forums.phpfreaks.com/topic/187003-_get/page/2/#findComment-987775
Share on other sites

Take a look at your urls. 

 

The format of a url is:

 

scheme://domain?param=value&parm2=value& etc.

 

 

Your url example is showing domain?param=value&?...

 

You can't have that question mark in there, it's a problem that is disrupting the parsing done by the webserver and subsequently the $_GET.

 

Also, when you have things like spaces in a url param, it needs to be handled aka, url encoded.  You should url encode your parameters.  PHP gives you a nice function to help you with this:

 

http://us2.php.net/urlencode

 

There are probably other logic issues with your code, but at least these will help you figure out some of the mystery.

 

 

Link to comment
https://forums.phpfreaks.com/topic/187003-_get/page/2/#findComment-987779
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.