On Sunday 14 November 2004 22:31, Stuart Felenstein wrote:
> After googling for quite some time I'm back asking
> here.  I want to be able to seperate by search and
> results into two pages.

Sadly, you're really not learning much from this list ...

> My form is set up on Search.php
> I have set action"searchresults.php"
>
> Couple of questions:
> I have my array of user selected options from my form
> element - Ind[]
>
> I gather the processing of the array needs to be done
> first before posting.
> I tried this:
> searchresults.php?Ind=<?php
> echo((isset($_POST["Ind[]"]))?$_POST["Ind[]"]:"") ?>
> but all I saw in the searchresults.php url was ..?ind
> =
> ?

... print_r()/var_dump() $_POST["Ind[]"], what do you see? Nothing I bet. Why? 
See manual > PHP and HTML for details.

Basically the contents of your form elements named 'Ind[]' have been placed in 
an array named 'Ind' and lives inside $_POST, ie $_POST['Ind'], and you can 
print_r() to see what it contains.

> Does the searchresults page need to use the GET method
> to gather up the variables?

Yes, if you're using this method to pass them on:

  searchresults.php?Ind...

Unfortunately, you can't just stick $_POST['Ind'] in there:

  searchresults.php?Ind[]=$_POST['Ind']

There are 2 way you can do this:

a) Pass the individual elements of $_POST['Ind']

or

b) serialize() $_POST['Ind'], pass it as a single element, then on the 
receiving page unserialize() it

Conceptually (a) will probably be easier to understand so:

you need to build a string which looks like:

  Ind[1]=value1&Ind[2]=value2...&Ind[n]=valuen

which you append to your URL like so:

  searchresults.php?Ind[1]=value1&Ind[2]=value2...&Ind[n]=valuen

This can be done using a foreach() on $_POST['Ind'], and implode(). Remember 
to validate each item as you go along.

And PLEASE, stick:

    error_reporting(E_ALL);
    ini_set('display_errors', TRUE);

on top of all your pages whilst you're developing.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Aw, screw it. It probably isn't all that good anyway.

Cartman, what are you talking about? You love Terrance and Philip!

Yeah, but the animation is crappy.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to