我需要显示var_dump
与所选国家' ,
但我不能这样做,因为$ res(array)$ id
<?php
if(isset ($_POST['submit']))
{
$id = $_POST['cata'];
$api = new SoapClient ( 'http://www.webservicex.com/globalweather.asmx?WSDL' );
$res = $api->GetCitiesByCountry(array( 'CountryName' =>"$id"));
var_dump($res);
}
?>
<form action="" name="cata">
<select>
<option>Israel</option>
<option>Egypt</option>
</select>
<br>
<input id='sumbit' name='submit' type='submit' value='tim'>
</form>
仍然无法正常工作,但我认为
中的问题
$res = $api->GetCitiesByCountry(array( 'CountryName' =>"$id"));
&#13;
答案 0 :(得分:0)
您需要将名称设为cata
以选择不形成标记的标记
<select name="cata"><option>Israel</option><option>Egypt</option></select>
还将方法post
放在表单标记
<form action="" method="post">
我认为网络服务正在运作:http://www.webservicex.com/globalweather.asmx?WSDL&CountryName=Israel
答案 1 :(得分:0)
将cata
定义为select
名称而不是form
名称
所以定义下面的表格
<form action="" method="post"> //<--- also set method for retrieving data in php
<select name="cata"> //<--here is the name field
<option>Israel</option>
<option>Egypt</option>
</select>
<br>
<input id='sumbit' name='submit' type='submit' value='tim'>
</form>
并在php中设置
$id = $_POST['cata']
答案 2 :(得分:0)
尝试运行此代码段。它应该适合你。 &#34; Alive to Die&#34;片段是未设置选项的值。
<?php
error_reporting(E_ALL); //check all type of error
ini_set('display_errors', 1); // display those errors
if (isset($_POST['submit'])) {
$id = $_POST['cata'];
$api = new SoapClient('http://www.webservicex.com/globalweather.asmx?WSDL');
$res = $api->GetCitiesByCountry(array('CountryName' => "$id"));
var_dump($res);
}
?>
<form action="" method="POST">
<select name="cata">
<option value="Israel">Israel</option>
<option value="Egypt">Egypt</option>
</select>
<br>
<input id='sumbit' name='submit' type='submit' value='tim'>
</form>
如果此代码仍未运行,请检查您是否启用了php_soap.dll扩展。要安装此软件包,请运行sudo apt-get install php-soap,然后从php.ini文件中取消注释以下行 延长= php_soap.dll