Question : Select menu to change MySQL Query

See my code below:

Javascript and Select menu code below:

*******************

<script>
function sel(x)
{
var divX = document.getElementById('placeholder');
divX.innerHTML = x;
}
</script>


<label>
          <select name="call_back_id" id="call_back_id" onchange="sel(this.value);">
            <?php
do {  
?>
            <option value="<?php echo $row_rs_call_back_request['id']?>"><?php echo str_pad($row_rs_call_back_request['id'], 6 , "0", STR_PAD_LEFT); ?> - <?php echo $row_rs_call_back_request['company']?> - Summary: <?php echo ucfirst(strtolower($row_rs_call_back_request['summary'])); ?></option>
            <?php
} while ($row_rs_call_back_request = mysql_fetch_assoc($rs_call_back_request));
  $rows = mysql_num_rows($rs_call_back_request);
  if($rows > 0) {
      mysql_data_seek($rs_call_back_request, 0);
        $row_rs_call_back_request = mysql_fetch_assoc($rs_call_back_request);
  }
?>
          </select>
        </label>

*******************************

I want to place the result of the below code which is based upon the above select menu:
 
 <div id="placeholder"><?php echo $row_rs_call_back_request['id']; ?></div>

In the below query where you see XXXX
 
        <?php
            $customer_id = $row_rs_call_back_request['id'];
            mysql_select_db($database_conn_tech8, $conn_tech8);
$query_rs_call_back_request2 = "SELECT cbr.*, cus.first_name, last_name, company, phone, email, address1, address2, town_city, county, post_code
                                             FROM call_back_request cbr
                                             JOIN customers cus
                                             ON cbr.customer_id = XXXX
                                             ORDER BY cbr.customer_id DESC";
$rs_call_back_request2 = mysql_query($query_rs_call_back_request, $conn_tech8) or die(mysql_error());
$row_rs_call_back_request2 = mysql_fetch_assoc($rs_call_back_request);
$totalRows_rs_call_back_request2 = mysql_num_rows($rs_call_back_request);
            ?>

How do I do this? Thanks

Answer : Select menu to change MySQL Query

You can, but then the rest of the function is pointless. Why would you update the contents of the <div> only to reload the page?

Here is my idea of how you want this to work:

  Page is requested
{server-side code}
  Select control populated from database query
  Page is displayed
{client-side code}
  Select control is updated
  Form is submitted
{server-side code}
  Database query is constructed from form data
...
Then something is presumably done with the returned record

Without the rest of the code, I really can't help any more than this.
Random Solutions  
 
programming4us programming4us