How do I create a function to retrieve values ??from the database

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..

This entry was posted in Codes & Scripts and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>