title: Trying to run a SELECT sql query based on the dropdown list result. mySQL php
body: <p>I haven't designed a website for about 3 years now, so I am quite rusty to say the least. I have to fall back on Dreamweaver CS5 to help me out.
  Right...</p>
  
  <p>I want a page for news, and the user/customer will select from a dropdown menu the date (JAN, FEB, MAR, APR etc...) Now, I have a table in my mySQL database called 'news' where each row is referenced by these dates. I have already set up a Dynamic List for the date (a dropdown list.)</p>
  
  <p>What I want is for the customer to select the date from the dropdown, and for the results to show in a Recordset underneath. I am assuming that the SQL query needs to be wrote something along the lines of:</p>
  
  <p>SELECT date, subject, message
  FROM news
  WHERE date = $ XXXXXDROPDOWNLIST XXX $</p>
  
  <p>As you can see, I made the last line up because I can't quite grasp how it should function. I am thinking that the dropdown list needs to be in a form which will POST and the table of results needs to be in a form which will GET. </p>
  
  <p>Could somebody more technical than me please enlighten my dillema?</p>
  
  <p>Thanks, Rob. </p>
  
  <p>Code</p>
  
  <pre><code>mysql_select_db($database_rcc, $rcc);
  $query_dropdowndate = "SELECT DATE_FORMAT(date, '%M %Y') AS FORMATTEDDATE FROM news GROUP BY FORMATTEDDATE ORDER BY Date DESC  ";
  $dropdowndate = mysql_query($query_dropdowndate, $rcc) or die(mysql_error());
  $row_dropdowndate = mysql_fetch_assoc($dropdowndate);
  $totalRows_dropdowndate = mysql_num_rows($dropdowndate);
  
  mysql_select_db($database_rcc, $rcc);
  $query_newsitems = "SELECT `Date`, Subject, Message FROM news WHERE date = $_POST['dropdowndate']";
  $newsitems = mysql_query($query_newsitems, $rcc) or die(mysql_error());
  $row_newsitems = mysql_fetch_assoc($newsitems);
  $totalRows_newsitems = mysql_num_rows($newsitems);
  ?&gt;
  
  
  
  &lt;form id="choosedate" name="choosedate" method="post" action="#"&gt;
    &lt;label for="dropdowndate"&gt;&lt;/label&gt;
    &lt;select name="dropdowndate" id="dropdowndate"&gt;
      &lt;?php
  do {  
  ?&gt;
      &lt;option value="&lt;?php echo $row_dropdowndate['FORMATTEDDATE']?&gt;"&lt;?php if (!(strcmp($row_dropdowndate['FORMATTEDDATE'], $row_dropdowndate['FORMATTEDDATE']))) {echo "selected=\"selected\"";} ?&gt;&gt;&lt;?php echo $row_dropdowndate['FORMATTEDDATE']?&gt;&lt;/option&gt;
      &lt;?php
  } while ($row_dropdowndate = mysql_fetch_assoc($dropdowndate));
    $rows = mysql_num_rows($dropdowndate);
    if($rows &gt; 0) {
        mysql_data_seek($dropdowndate, 0);
        $row_dropdowndate = mysql_fetch_assoc($dropdowndate);
    }
  ?&gt;
    &lt;/select&gt;
    &lt;input type="submit" name="submit" id="submit" value="Submit" /&gt;
  &lt;/form&gt;
  &lt;p&gt;&amp;nbsp;&lt;/p&gt;
  &lt;form id="form1" name="form1" method="get" action=""&gt;
    &lt;table border="0" cellpadding="5" cellspacing="2"&gt;
      &lt;tr&gt;
        &lt;td&gt;Date&lt;/td&gt;
        &lt;td&gt;Subject&lt;/td&gt;
        &lt;td&gt;Message&lt;/td&gt;
      &lt;/tr&gt;
      &lt;?php do { ?&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;?php echo $row_newsitems['Date']; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row_newsitems['Subject']; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row_newsitems['Message']; ?&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;?php } while ($row_newsitems = mysql_fetch_assoc($newsitems)); ?&gt;
  </code></pre>
  
  <p>Some of this may look weird so let me explain... The dynamic list (dropdown) is called 'dropdowndate' and the form is called 'choosedate' There is a button called 'submit' to submit the form. FORMATTEDDATE is the name given to the recordset which gives the dropdown menu a dynamic list. </p>
  
  <p>I want the value from that dynamic list when user's POST, to insert into the query as i mentioned ... SELECT <code>Date</code>, Subject, Message FROM news WHERE date = $_POST['dropdowndate']";  (THIS BIT IS PROBABLY WRONG)</p>
  
  <p>Rob</p>