Jump to content

sparhawks

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Everything posted by sparhawks

  1. Thanks, I gave it a try, but i get two warnings. Warning: Invalid argument supplied for foreach() on line 12 Warning: implode() [function.implode]: Invalid arguments passed in on line 20 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>TEST</title> </head> <body> <?php $arr=$_POST['text']; $i=0; foreach ($arr as $key => $value) { if ($value != "") { $variables[$i] = $value; } $i++; } // implode: $list = implode(",", $variables); ?> LIST: <? echo $list; ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="checkbox" name="text[1]" value="1"/> Calm<br/> <input type="checkbox" name="text[2]" value="2"/> Bourke<br/> <input type="checkbox" name="text[3]" value="3"/> Playful<br/> <input type="checkbox" name="text[4]" value="4"/> Shopping <input type="submit" name="btnSendForm" value="Submit" /> </form> </body> </html> Have i missed anything?
  2. I have a PHP post form that posts up to 4 variables. I need whatever variables are passed to be combined into one comma seperated string (eg variable1,variable2,variable3,variable4). This i can do with the code below. $combo = array($one, $two, $three, $four); $list = implode(",", $combo); my problem is that the form fields are optional by design so that the user doesn't always post all 4 variables. Sometimes they will post 1, sometimes they will post all 4. So if a user only selects two fields and submits the form i will end up with a string looking like: variable1,variable2,, when what i really want is (note the removal of the trailing commas at the end of the string): variable1,variable2 Can anyone point me towards a possible solution for this?
  3. Sorry my question may have been unclear, your suggestion would work but I would rather keep it dynamic so users can elect to select a Month first, then if they want to drill down further they can select a Day as well. If i group them together as you suggested then i will have to provide a long list of URL's. Ideally i would have a list of URL's January to December, then another list of URL's Monday to Sunday. A User can then select a month (eg. index.php?month=January) then they can select a day (eg. index.php?month=January&day=Monday). Then if they wanted to change month they could choose a new month (eg. index.php?month=February&day=Monday)
  4. Hello. i am after some coding help, hope someonce can point me in the right direction. Passing variables via HREF and retrieving them with GET. Is there a way of appending multiplevariables to the URL? <a href="?month=January">January</a> <a href="?month=February">February</a> <a href="?day=Monday">Monday</a> <a href="?day=Tuesday">Tuesday</a> eg. If i click the January link above my page will change to index.php?month=January. Then if i click Monday i would like my URL to change to index.php?month=January&day=Monday. Likewise if i have index.php?month=January&day=Monday and then click Tuesday i would like URL to replace day=Monday to day=Tuesday. Is this posssible at all? not sure where to start searching.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.