php $ _POST没有发送全部价值

时间:2013-11-05 22:03:05

标签: php mysql

update.php

$q = mysql_query("SELECT id FROM performer WHERE username='$user' LIMIT 1") or die("Error : " . mysql_error());
$r = mysql_fetch_assoc($q);
$id = $r['id'];

$query = mysql_query("SELECT baned_c, baned_c2, baned_c3 FROM performer_s WHERE id='$id' LIMIT 1");
$result = mysql_fetch_assoc($query);
if($result['baned_c'] == NULL) { $res1 = "NONE"; } else { $res1 = $result['baned_c']; }

<?php

echo "<form method=post action=insert.php>";

echo "<select name=country>";
echo "<option value=>NONE</option>";
$country = mysql_query("SELECT DISTINCT country_name FROM country_list ORDER BY country_name ASC");
while($next = mysql_fetch_assoc($country))
{
if($next['country_name'] == $res1)
{
    echo "<option selected value=" . $next['country_name'] . ">" .     $next['country_name'] . "</option>";
}
else
{
    echo "<option value=" . $next['country_name'] . ">" . $next['country_name'] . "</option>";
}
}
echo "</select>";
echo "<br /><input type=submit value=Update List />";
echo "</form>";
mysql_close();

insert.php

$country1 = $_POST['country'];
$user = $_SESSION['MM_Username'];
$query = mysql_query("SELECT id FROM performer WHERE username='$user' LIMIT 1") or die("Error : " . mysql_error());
$row = mysql_fetch_assoc($query) or die("Error : " . mysql_error());
$id = $row['id'];
if(isset($country1)) { mysql_query("UPDATE performer_s SET baned_c='$country1' WHERE id='$id'") or die("Error : " . mysql_error()); }

你好2全新,这里很新,很高兴见到你。

希望你能帮助我

这里是我的2页update.php和insert.php

我的问题:

如果$ country1 = $ _POST ['country'];是一个单词的国家一切都很好,但如果它是一个两个字的国家$ _POST只给我第一个字

$country1 = $_POST['country'];
if its AMERICA its OK
if its REPUBLIC OF KOREA NOT OK i only get REPUBLIC

我能做什么?

1 个答案:

答案 0 :(得分:2)

尝试更改:

echo "<option value=" . $next['country_name'] . ">" .     $next['country_name'] . "</option>";

有:

echo "<option value=\"" . $next['country_name'] . "\">" . $next['country_name'] . "</option>";

基本上,您现在正在生成此HTML:

<option value=REPUBLIC OF KOREA>REPUBLIC OF KOREA</option>

你应该生成这个HTML:

<option value="REPUBLIC OF KOREA">REPUBLIC OF KOREA</option>

顺便说一句,做同样的事情(将" s)添加到另一个echoselected)。