2011-12-13 48 views
0

我正在做一個條件表單,並且據我所知,除非它的工作不正常,否則一切都是正確的。即時通訊嘗試將我的價值觀傳遞給if語句,但它並沒有得到它們,它一直在迴應我的其他陳述。獲取名稱的條件表格

這是我

<form action="" method="post"> 
<select name="optionType" onChange="this.form.submit();"> 
<option value="Ben">Ben</option> 
<option value="John">John</option> 
<option value="Matt">Matt</option> 
</select> 
</form> 

<table> 

<? 
for($x=2; $x<=count($excel->sheets[0]["cells"]); $x++) { 
    $date = $excel->sheets[0]["cells"][$x][1]; 
    $user = $excel->sheets[0]["cells"][$x][2]; 
    $type = $excel->sheets[0]["cells"][$x][3]; 
    $keywords = $excel->sheets[0]["cells"][$x][4]; 
    $keywordpage = $excel->sheets[0]["cells"][$x][5]; 
    $urls = $excel->sheets[0]["cells"][$x][6]; 
    $sitepr = $excel->sheets[0]["cells"][$x][7]; 

    echo "\t<tr>\n"; 
    if($user == $_POST['optionType']) { 
     echo "<td>"; 
    echo $date = $excel->sheets[0]["cells"][$x][1]; 
    echo "</td>\n"; 

    echo "<td>"; 
    echo $user = $excel->sheets[0]["cells"][$x][2]; 
    echo "</td>\n"; 

    echo "<td>"; 
    echo $type = $excel->sheets[0]["cells"][$x][3]; 
    echo "</td>\n"; 

    echo "<td>"; 
    echo $keywords = $excel->sheets[0]["cells"][$x][4]; 
    echo "</td>\n"; 

    echo "<td>"; 
    echo $keywordpage = $excel->sheets[0]["cells"][$x][5]; 
    echo "</td>\n"; 

    echo "<td>"; 
    echo $urls = $excel->sheets[0]["cells"][$x][6]; 
    echo "</td>\n"; 

    echo "<td>"; 
    echo $sitepr = $excel->sheets[0]["cells"][$x][7]; 
    echo "</td>\n"; 
    }else{ 
    echo 'Nothing at this time'; 
    } 
    echo "\t</tr>\n"; 
} 

    ?> 
    </table> 

任何幫助表示讚賞 謝謝

+0

你想用`value =「<?php echo $ userinfo ='Ben'做什麼??>」`?爲什麼不`價值=「本」`?事實上,我想知道爲什麼你使用`echo $ var ='value';`everywhere ...你是否有一個名爲`userinfo`的字段,你期望發佈數據? `$ user`沒有在腳本中檢查其值的位置定義? – 2011-12-13 23:49:01

+0

它爲我的代碼更進一步下線,更新我的代碼,所以你可以得到更好的理解 – user874185 2011-12-13 23:53:46

回答

1

它看起來像問題是這個$_POST['userinfo']。您的選擇框未命名爲userinfo。它的名字叫做optionType。所以你永遠不會從你的表單中獲得一個用戶。