Ask a Question related to PHP Development, Design and Development.
-
Ryan A #1
foreach help in search
Hi,
I have a search page that is working perfectly so far and i have paginated
it, the problem is the "next" page is giving me a slight problem.
I am sending around 30 parameters via a $_GET and the "next" page must get
the same parameters with the $page+1...instead of doing it manually I have
tried using a foreach loop but I guess i am doing something wrong as i still
dont understand them very well, my requirment is pretty simple get all the
$_GET variables and their values into another variable or array and +1 the
$page variable(I am getting a $_GET['page'] which is an int)
Looking at the manuals examples I have experimented with this example
"foreach (array_expression as $key => $value) statement"
using this:
foreach ($_GET as $a => $v) {
print "Current value of \$a: $v.\n";
}
(Chapter 11. Control Structures) but no success.
Kindly help.
Thanks,
-Ryan
We will slaughter you all! - The Iraqi (Dis)information ministers site
[url]http://MrSahaf.com[/url]
Ryan A Guest
-
ANN: InterAKT Site Search - search in multiple tables
Hello, We have just released a new product, MX Site Search, meant to help web developers and designers create a search form in their dynamic... -
foreach
Hello all While traversing a loop across and array, how can I access array positions further down the array, like say if I am on a loop looking at... -
#25786 [NEW]: PHP website uses cookies to remember last search phrase in search box
From: tipsen at imada dot sdu dot dk Operating system: - PHP version: Irrelevant PHP Bug Type: Unknown/Other Function Bug... -
Half solved (was foreach in search)
Hi, I am getting a lits of GET values and dumping the variable and the value into an array like so: $xxx=0; foreach ($_GET as $a => $v) {... -
if-map vrs foreach-if
I have this piece of code ($db_keywords is an array ref of array references): if(map($_-> =~ /\b$keyword\b/i,@$db_keywords)) { print "Matched... -
Ryan A #2
Re: [PHP] foreach help in search
Hi,
thanks for replying, I am not very good with the "list" function thats why i
use foreach instead.
My new problem is that i also have to take out the PHPSESSID if it exists
and its value otherwise i am getting 2 PHPSESSID's in my url...how can i do
that with your sample code?
Thanks,
-Ryan
> Personally, I like list() + each() + while() combo, like so :
>
> while(list($key,$val) = each($_GET)){
> if ($key == "page")
> {
> $newpage = $val + 1;
> $getstring .= $key&$newpage;
> } else { $getstring .=$key&$val; }
> }
> $url = "page.php?"+$getstring;
>
> As a side note, PHP is not strictly typed. So you aren't getting an
> int per se, just a string that's a number :)
>
> --
> Regards,
> Burhan Khalid
> phplist[at]meidomus[dot]com
> [url]http://www.meidomus.com[/url]>Ryan A Guest



Reply With Quote

