Reply to Re: Problem with array...

Your name:

Reply:


Posted by J.O. Aho on 02/01/06 16:02

Leszek wrote:
> I have a form with 5 dropdown lists I want to put all selected values to an
> array called $data[] so i wrote sometthing like this:
>
> for(i=0;i<5;i++){
> echo"<select name=\"\$data[]\">";
> echo"<option value=\"1\">1</option>";
> echo"<option value=\"1\">2</option>";
> echo"<option value=\"1\">3</option>";
> echo"</select>";
> }
>
> So I think this will put all selected values into an array.
> But the problem is that when user submits the form this array goes to $_POST
> array
> And I have no idea how to read a value from an array $data which is into
> array $_POST and use it as a part of "if" statement


$value_from_array=$_POST['$data'];
//for example
if ($value_from_array[0]==5){
// instructions
}

But would be easier you didn't use the $ in the name

for(i=0;i<5;i++){
echo"<select name=\"\data[]\">";
echo"<option value=\"1\">1</option>";
echo"<option value=\"1\">2</option>";
echo"<option value=\"1\">3</option>";
echo"</select>";
}

$value_from_array=$_POST['data'];
if ($value_from_array[0]==5){
// instructions
}



//Aho

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация