MySQL passing variable to dynamic query

alexdirrno

New Member
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:\[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\]I've managed to create this on the server as table_view (without the filter) which i am able to retrive ok.\[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\]I can filter this:\[code\]$query_rs_table = sprintf("SELECT * FROM table_view WHERE idimg_tbl = ".$myparam."";\[/code\]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.i hope that makes sense.thanks
 
Back
Top