Is it possible to delete a query from a URL?
I tried unset($_get[submit]) but it did not do as I thought. I thought it would remove it from the URL string so all my links on the page that I generate dynamically would appear without &Submit=submit.
Is there some other function I need to look into that may help?
On a side not do people know of any good tutorials on using functions & classes? I feel comfortable with the basics of PHP and would now like to take the next steps in creating more efficient code.
Cheers
Jim
Deleting a query value from a URL
Moderator: General Moderators
-
Bennettman
- Forum Contributor
- Posts: 130
- Joined: Sat Jun 15, 2002 3:58 pm
What I do, is to recreate the string using $_GET, with a simple validation on what's what.
Code: Select all
<?php
foreach ($_GET as $key => $value) {
if ($key != 'submit') $get_string .= $key.'='.$value.'&';
}
?>Yeah I know that.Weirdan wrote:post your code. PHP itself does not generate &Submit=submit, it's you code where this parameter is added.
I have a form on my page that allows a user to filter the displayed results from a table.
There may be more than 1 page of results after filtering so I wish to be able to pass the filter parameters onto the next page.
I use PHP 5 function http_build_query($_GET) to grab the URL query so I can build it into my page links. I think Bennettman has given me the answer I was looking for.
Another question.
I have employed Bennettman's code to generate my URL query
Now my page links <a href tag looks like this:
Note I changed Bennettman's $get_string var to $geturl to fit in with what I was already working with.
Code: Select all
// Create page number links
for ($i = 0; $i < $pages; $i++) {
$url = "pageid=" . $i;
if ($i == $pageid)
{
echo " <font class="CurrentPage">".($i + 1)."</font> ";
} else {
echo " <span class="Smallarticletext"><a href="test.php?". $geturl ."&". $url ."">".($i + 1)."</a></span> ";
}
}test.php?&product=product1&pageid=1
So when I click on this all the correct parameters are passed on to the next page. But on this next page when i look at the a href it looks like this:
test.php?&product=product1&pageid=1&pageid=2
It appends the same pageid query onto the end of the url. All still works fine I presume because the latter pageid query is dominant.
What do I need to do to stop this though?
-
Bennettman
- Forum Contributor
- Posts: 130
- Joined: Sat Jun 15, 2002 3:58 pm