title: MySQL passing variable to dynamic query
body: <p>sorry if this is a basic question!
  up till now i have been creating mysql queries in php and passing across variables within the sql call like this:</p>
  
  <pre><code>$myparam = $_GET["id_tbl"];
  
  mysql_select_db($database_camerich, $camerich);
  $query_rs_table = sprintf("SELECT * FROM table_tbl WHERE idimg_tbl = ".$myparam." ORDER BY order_tbl ";
  $rs_table = mysql_query($query_rs_table, $camerich) or die(mysql_error());
  $row_rs_table = mysql_fetch_assoc($rs_table);
  $totalRows_rs_table = mysql_num_rows($rs_table);
  </code></pre>
  
  <p>I've managed to create this on the server as table_view (without the filter) which i am able to retrive ok.</p>
  
  <pre><code>mysql_select_db($database_camerich, $camerich);
      $query_rs_table = sprintf("SELECT * FROM table_view";
      $rs_table = mysql_query($query_rs_table, $camerich) or die(mysql_error());
      $row_rs_table = mysql_fetch_assoc($rs_table);
      $totalRows_rs_table = mysql_num_rows($rs_table);
  </code></pre>
  
  <p>I can filter this:</p>
  
  <pre><code>$query_rs_table = sprintf("SELECT * FROM table_view WHERE idimg_tbl = ".$myparam."";
  </code></pre>
  
  <p>i would like to know how to set up a filter on the query dynamically on the server rather than filtering the results in php after the the query is returned.</p>
  
  <p>i hope that makes sense.</p>
  
  <p>thanks</p>