Last active
January 14, 2018 06:01
-
-
Save arif98741/636eeda31680c9001d7791f5978269ae to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
//using mysqli_connect. it is about dead nowadays | |
$link = mysql_connect("localhost", "root", ""); | |
mysql_select_db("test", $link); | |
$result = mysql_query("SELECT * FROM user", $link); | |
//always try to use if condition for skipping errors | |
if($result) | |
{ | |
$num_rows = mysql_num_rows($result); | |
//it will not mysqli_num_rows | |
//mysqli_num_rows will be used at time of using mysqli class | |
echo $num_rows." Row"; | |
} | |
?> | |
<br/> | |
<?php | |
//using mysqli class. this is the best. | |
$link = new mysqli("localhost", "root", "","test"); | |
if($link) | |
{ | |
$result = $link->query("SELECT * FROM user"); | |
//always try to use if condition for skipping errors | |
if($result) | |
{ | |
$num_rows = $result->num_rows; | |
echo $num_rows." Row"; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment