Skip to content

Instantly share code, notes, and snippets.

@razbakov
Created November 24, 2010 19:57
Show Gist options
  • Save razbakov/714281 to your computer and use it in GitHub Desktop.
Save razbakov/714281 to your computer and use it in GitHub Desktop.
Just For Fun
<?php
$db = mysql_connect ('localhost','root','12345');
mysql_query('SET NAMES UTF8');
mysql_query('SET character_set_client="UTF8"');
mysql_query('SET character_set_cоnnectiоn="UTF8"');
mysql_query('SET character_set_results="UTF8"');
mysql_query('SET character_set_server="UTF8"');
mysql_select_db ('blog,$db);
function rowsNum($table_title, $par = null) {
$request = "SELECT COUNT(";
if (isset($par)) {
$sw = 1;
if (is_array($par)){
$request .= $par[0];
$end = $par[1];
}
else
$end = $par;
}
if (!$sw)
$request .= "id";
$request .= ") AS count FROM ".$table_title;
if (isset($end))
$request .= " ".$end;
echo $request."<br />";
return mysql_query($request, $this->db);
}
echo rowsNum('posts');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment