foreach help in search

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. #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...
    4. 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) {...
    5. 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...
  3. #2

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139