Created
November 24, 2010 19:57
-
-
Save razbakov/714281 to your computer and use it in GitHub Desktop.
Just For Fun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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