Pass arrays from page a to b
Moderator: General Moderators
Pass arrays from page a to b
I wander if I can pass arrays from page a to page b with the a tag (without the use of forms).
Thanks.
Thanks.
Last edited by Oren on Tue Jun 06, 2006 3:55 am, edited 1 time in total.
twigletmac | Please use
page b:
Thanks for everything
twigletmac | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
page a:Code: Select all
while (($file2 = readdir($open_folder)) !== false)
{
if ($file2 != "." AND $file2 != ".." AND $file2 != "Thumbs.db")
{
if ($_POST['change'.$file_id] == "on")
{
$to_used[$file_to] = $file2;
$file_to++;
}
$file_id++;
}
}
closedir($open_folder);
$to_used = serialize($to_used);
<a href="<?php echo $url."&fileto=".$file_to."&to_used=".$to_used; ?>" target="index">Bip Bip !!!</a>Code: Select all
$file_id = 0;
$to_used = unserialize($to_used);
while ($file_id < $fileto)
{
echo $to_used[$file_id];
$file_id++;
}twigletmac | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Code: Select all
<a href="?foo[]=42&foo[]=10&foo[]=12">Click me</a>
<?php
if (isset($_GET['foo']))
{
print_r($_GET['foo']; //array( 42, 10, 12 )
}
?>There is no point to post the whole code. Next time post only the relevant code.
This is enough:
Now change it to this and tell us what happens:
This is enough:
Code: Select all
$to_used = serialize($to_used);
<a href="<?php echo $url."&fileto=".$file_to."&to_used=".$to_used; ?>" target="index">Bip Bip !!!</a>Code: Select all
$file_id = 0;
$to_used = unserialize($to_used);Code: Select all
$to_used = urlencode(serialize($to_used));
<a href="<?php echo $url."&fileto=".$file_to."&to_used=".$to_used; ?>" target="index">Bip Bip !!!</a>Code: Select all
$file_id = 0;
$to_used = urldecode(unserialize($to_used));