oni-kun Posted January 3, 2010 Share Posted January 3, 2010 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" Quote Link to comment https://forums.phpfreaks.com/topic/187003-_get/page/2/#findComment-987552 Share on other sites More sharing options...
justAnoob Posted January 3, 2010 Author Share Posted January 3, 2010 <a href="$targetpage" . "page=$counter" shouldn't it be <a href="$targetpage" . "?page=$counter" Quote Link to comment https://forums.phpfreaks.com/topic/187003-_get/page/2/#findComment-987556 Share on other sites More sharing options...
oni-kun Posted January 3, 2010 Share Posted January 3, 2010 <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. Quote Link to comment https://forums.phpfreaks.com/topic/187003-_get/page/2/#findComment-987557 Share on other sites More sharing options...
justAnoob Posted January 3, 2010 Author Share Posted January 3, 2010 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; ?> Quote Link to comment https://forums.phpfreaks.com/topic/187003-_get/page/2/#findComment-987775 Share on other sites More sharing options...
gizmola Posted January 3, 2010 Share Posted January 3, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/187003-_get/page/2/#findComment-987779 Share on other sites More sharing options...
justAnoob Posted January 3, 2010 Author Share Posted January 3, 2010 I took out the extra '?' and the pagination shows up and everything works now (I could of swore that I tried that, lol) But when the page loads (page 1 it would be) I still get that undefined index. I will take a look,, thanks for everything. Quote Link to comment https://forums.phpfreaks.com/topic/187003-_get/page/2/#findComment-987787 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.