title: Disable input element based on PHP variable value
body: <p>How would I disable specific input elements based on the value of a PHP variable? </p>
  
  <p><strong>Example HTML</strong></p>
  
  <pre><code>&lt;?php 
  
  $stock_count = 1; 
  
  ?&gt;
  
  &lt;td width="252" valign="top"&gt;
            &lt;a href="action-sale.php?size=&lt;?=$size_quantity?&gt;_con_b&amp;amp;id=&lt;?=$product['product_id'];?&gt;&amp;barcode=&lt;?=$barcode?&gt;&amp;shop_price=&lt;?=$product['price']?&gt;&amp;amp;brand=&lt;?=$product['brand_id']?&gt;&amp;amp;title=&lt;?=$product['title']?&gt;"&gt;
            &lt;input name="button5" type="submit" class="submit-button-green"
                   id="sale" value="CONCESSION PRODUCT SOLD" style="width:100%" onclick="this.disabled=1;"/&gt;
            &lt;/a&gt;
          &lt;/td&gt;
          &lt;td align="right"&gt;
              &lt;a href="action-delivery.php?size=&lt;?=$size_quantity?&gt;_con_b&amp;amp;id=&lt;?=$product['product_id'];?&gt;&amp;barcode=&lt;?=$barcode?&gt;"&gt;
                &lt;input name="button" type="submit" class="submit-button"
                       id="delivery" value="PRODUCT DELIVERED" style="width:170px" onclick="this.disabled=1;"/&gt;
                &lt;/a&gt;
          &lt;/td&gt;
  </code></pre>
  
  <p><strong>Condition</strong> </p>
  
  <pre><code>    IF ($stock_count &lt;= 0) 
  {
      Disable ID 'Sale' 
  }
  ELSE IF ($stock_count &gt; 0) 
  {
      Do not disable anything
  }
  </code></pre>
  
  <p>So based on the condition above the <code>disabled</code> attribute would be added to the <code>sale</code> input button. If the value of the <code>$stock_count</code> variable is greater than 0 than no action will be needed. </p>
  
  <p>Any advice appreciated. 
  Thanks</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I managed to solve the issue with the following code: </p>
  
  <pre><code> $disabled = $stock_count &gt; 0 ? "" : "disabled";
  
   &lt;input name="sale" type="submit" class="submit-button-green" 
                   id="sale" value="PRODUCT SOLD" style="width:100%"
                   onclick="location.href='action-sale.php'"; &lt;?php echo $disabled; ?&gt; /&gt;
  </code></pre>