Reputation: 853
Im doing a conditional form and as far as I can tell everything is correct except its just not working correctly. im trying to pass my values into a if statement and its just not getting them, it keeps echoing out my else statement.
This is what I have
<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>
Any help is appreciated thank you
Upvotes: 0
Views: 59
Reputation: 1354
It looks like the issue is this $_POST['userinfo']
. Your select box isn't named userinfo
. It's named optionType
. So you never get a user passed from your form.
Upvotes: 1