I want to create a function to call a key and value on specific table.
Basically my statement like this
$query = 'SELECT SQL_CALC_FOUND_ROWS
'.$key.'
FROM users
开发者_如何学编程 WHERE
status="'.$value.'"';
Now I want implement in function
function counter('what to put here') {
$query = 'SELECT SQL_CALC_FOUND_ROWS
'.$key.'
FROM users
WHERE
status="'.$value.'"';
if (!($result = @mysql_query($query))) {
die(mysql_error());
}
$rows = mysql_fetch_assoc(mysql_query('SELECT FOUND_ROWS() AS rows'));
return $rows['rows']; // what to return here
}
And to call the function
<?php echo counter('KEY','VALUE'); ?>
Let me know how to achieve my goal..
So ,I've understand the question , according to poster's comment and I'm posting the answer:
You need to define your function like this:
function counter($key,$value)
and you get the result like this: echo counter('key','value')
This is how you define your function:
function counter($key)
This is how you can call it:
<?php echo counter('KEY'); ?>
精彩评论