2013-05-20 3 views
0

코드가 제대로 작동하지 않습니다. 내가 원하는 경우 user's select country from drop down select list? 양식 제출 후 값은 courier array에 저장해야합니까? 사용자가 값을 다음 $_SESSION['country1']=$abc; 생성한다 서로 일치하는 경우는 다음 미국 abc courier array values 일치되어야 미국 선택한 경우변수 값을 배열에 전달하는 방법은 무엇입니까?

예를 들어

?

Senorio

난 두 개의 서로 다른 택배 회사를 가지고 내가 다른 페이지로 택배 회사에 따라 국가 목록을 전달하고 싶으십니까? 하나의 요소에서 $ abc 방송과 $ XYZ 결과

인덱스 페이지

<?php 
session_start(); 
if(isset($_REQUEST['test'])) 
{ 
$newcountry=$_POST['country']; 

//Let's Assume Courier Companies Is Abc 
$abc=array($newcountry=>'Usa',$newcountry=>'Uk'); 

//Let's Assume Another Courier Companies Is Xyz 
$xyz=array($newcountry=>'Singapore',$newcountry=>'Germany'); 

$_SESSION['country1']=$abc; 
$_SESSION['country2']=$xyz; 

if(isset($_SESSION['country1']) && isset($_SESSION['country2'])){ 
header('Location:test.php'); 
}} 
?> 

<form method="post"> 
<select name="country" id="country"> 
<option value="Usa">Usa</option> 
<option value="Uk">Uk</option> 
<option value="Germany">Germany</option> 
<option value="Singapore">Singapore</option> 
<input type="submit" name="test" value="Submit" /> 

</select> 
</form> 

Test.php는

session_start(); 
echo $country2=implode($_SESSION['country1']); 

답변

0
$newcountry=$_POST['country']; 

//Let's Assume Courier Companies Is Abc 
$abc=array($newcountry=>'Usa',$newcountry=>'Uk'); 

//Let's Assume Another Courier Companies Is Xyz 
$xyz=array($newcountry=>'Singapore',$newcountry=>'Germany'); 

배열 할당. $ usc = array ("Usa"=> "Uk")와 $ xyz = array ("Usa"=> "Germany")가 선택되면 $ newcountry의 값은 같고 후자의 값은 재설정됩니다 형식적인 가치.

+0

'test.page'에 echo $ country2 = implode ($ _ SESSION [ 'country1']);를 입력하면 usauk가 함께 표시되지만 사용자 또는 고객의 국가를 선택한 다음 국가 값을 확인해야합니다 배열에 다음 그것은 사용자 또는 고객에 의해 선택 에코 단일 국가 것입니다? –

관련 문제