How to combine two segments of code into a function PHP MySQL asp c select
//php$query_hx_php= "SELECT * FROM content_publish WHERE content_language_classification = 'php' group by content_original_autor ORDER BY content_id DESC";$record_php = mysql_query($query_hx_php);$record_cnt_php = mysql_num_rows($record_php);//asp$query_hx_asp= "SELECT * FROM content_publish WHERE content_language_classification = 'asp' group by content_original_autor ORDER BY content_id DESC";$record_asp = mysql_query($query_hx_asp);$record_cnt_asp = mysql_num_rows($record_asp);
// I hope that the extension name, such as _ asp _ php, can be changed according to parameter changes. for example, if I pass in c, the extension name of the variable is changed to *** _ c.
Reply to discussion (solution)
function aa($str){ $str1 = '$'.$str; $query_hx_.$str1= "SELECT * FROM content_publish WHERE content_language_classification = 'asp' group by content_original_autor ORDER BY content_id DESC"; $record_.$str1 = mysql_query($query_hx_asp); $record_cnt_.$str1 = mysql_num_rows($record_asp); }
What are so many variables?
Function foo ($ a) {$ query_hx_php = "SELECT * FROM content_publish WHERE region = '$ a' group by content_original_autor order by content_id DESC"; $ record_php = mysql_query ($ query_hx_php ); $ record_cnt_php = mysql_num_rows ($ record_php); return $ record_cnt_php; // modify the return value as needed}