title: PHP Select Statement bound to input box
body: <p>I have a database table that contains fields including category (cat) and posting price (postprice).  I need to bind an input field on my web page to the postprice value corresponding to the category selected in the dropdown box on the same page.  I'm seeing syntax error but am not sure what it is.  Here's the code for the dropdown box:</p>
  
  <pre><code>&lt;select name="postcat" class="req" style="width:220px" onchange="getCats(this.value);"&gt;
  &lt;?php
  if ($_POST['postsubcats'] == "none") {
  echo "&lt;option value=\"none\" selected=\"selected\"&gt;Select a category&lt;/option&gt;";
  } else {
  echo "&lt;option value=\"none\"&gt;Select a category&lt;/option&gt;";
  }
  
  ?&gt;
  &lt;?php
  
  $querycat = "SELECT * FROM `index` LIMIT 0, 30 ";
  $resultcat = mysql_query($querycat);
  
  while($rowcat = mysql_fetch_array($resultcat)){
  echo "&lt;option value=\"" . $rowcat['cat'] . "\"&gt;" . $rowcat['title'] .  "&lt;/option&gt;\n";
  }
  
  ?&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Here's the snippet for the input box:</p>
  
  <pre><code>&lt;input type="text" id="adFee" name="adfee" contenteditable="false" 
  value="&lt;?php SELECT 'postprice' FROM 'index' WHERE 'cat' = $_POST(['postcat']); ?&gt;"&gt;
  </code></pre>
  
  <p>Thanks much for your help.</p>
  
  <p><strong>Edit</strong>
  Thanks to Mash, I've modified my code as follows:</p>
  
  <pre><code>&lt;label&gt;Posting Fee:&lt;/label&gt;&lt;br/&gt;
  &lt;?php
  $queryprice =  "SELECT 'postprice' FROM 'index' WHERE 'cat' = " . $_POST('postcat'); 
  $resultprice = mysql_query($queryprice);  
  while($row= mysql_fetch_array($resultprice)){   
  echo '&lt;input type="text" id="adFee" name="adfee" contenteditable="false" value="';   
  echo $row['postprice'] . '" /&gt;';
  } ?&gt;
  </code></pre>
  
  <p>I now receive Fatal Error: Function name must be a string.  Am I missing a ' " or ; somewhere??</p>
  
  <p>Fatal Error is resolved.  New Error: </p>
  
  <pre><code>mysql_fetch_array(): supplied argument is not a valid MySQL result resource 
  </code></pre>
  
  <p>Revised Code:</p>
  
  <pre><code>&lt;?php
  
  $queryprice =  "SELECT postprice FROM 'index' WHERE cat = '" . mysql_real_escape_string($_POST['postcat'])."'"; 
  
  $resultprice = mysql_query($queryprice);  
  
  while($row= mysql_fetch_array($resultprice)){   
  
  ?&gt;&lt;input type="text" id="adFee" name="adfee" contenteditable="false" value="&lt;?php echo $row['postprice'];?&gt;"&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>Does this mean that my code block is not "seeing" the option field postcat?</p>