PHP - not sure how to ask - regarding variables and $_POST
<p>I have a PHP form. The form works but I'm trying to test to see if a value other than the first item has been selected. I can't figure out how to write the If statement.</p>

<pre><code>$products = array(
 '' =&gt; 1,
 'Item 2' =&gt; 2,
 'Item 3' =&gt; 3,
 'Item 4' =&gt; 4,
 'Item 5' =&gt; 5,
 'Item 6' =&gt; 6
);

$html = generateSelect('products', $products);

function generateSelect($name = '', $options = array()) {
 $html = '&lt;select name="'.$name.'"&gt;';
 foreach ($options as $option =&gt; $value) {
  $html .= '&lt;option value='.$value.'&gt;'.$option.'&lt;/option&gt;';
 }
 $html .= '&lt;/select&gt;';
 return $html;
}
</code></pre>

<p>In my table, the drop down box is displayed:</p>

<pre><code>&lt;tr&gt;
&lt;td style="width:{$left_col_width}; text-align:left; vertical-align:center; padding:{$cell_padding}; font-weight:bold; {$product[3]}"&gt;{$product[0]}&lt;/td&gt;
&lt;td style="text-align:left; vertical-align:top; padding:{$cell_padding};"&gt;&lt;select name="{$product[1]}"&gt;
 &lt;option value="1"&gt;&lt;/option&gt;
 &lt;option value="2"&gt;Item 2&lt;/option&gt;
 &lt;option value="3"&gt;Item 3&lt;/option&gt;
 &lt;option value="4"&gt;Item 4&lt;/option&gt;
 &lt;option value="5"&gt;Item 5&lt;/option&gt;
 &lt;option value="6"&gt;Item 6&lt;/option&gt;
&lt;/select&gt;&lt;/td&gt;
&lt;/tr&gt;
</code></pre>

<p>I use the following if statement to check to see if someone has entered a phone number. if they have not entered a phone number, then the "Phone:" text turns red. How do I do an if statement similar to this to verify that someone has selected a product option from the drop down box?</p>

<pre><code>  if(!empty($_POST['phone'])) {
   $phone[2] = clean_var($_POST['phone']);
   if (function_exists('htmlspecialchars')) $phone[2] = htmlspecialchars($phone[2], ENT_QUOTES);
  }
  else {
    $error = 1;
    $phone[3] = 'color:#d20128;';
  } 
</code></pre>

<p>it seems simple but I can't figure it out. </p>

<p>EDIT 1:</p>

<p>I tried the suggestions, and the following works best so far:</p>

<pre><code>if ($_POST['product'] != 1){
</code></pre>

<p>after I click the 'submit' button. the "Product:" text does turn red like expected; however, the drop down box resets to showing the option value 1 but the variable still remains at the selected value.</p>

<p>long questions short. how do I tell the dropdown box to show, for example, item 5?</p>
