Skip to content

Instantly share code, notes, and snippets.

@arif98741
Last active January 14, 2018 06:01
Show Gist options
  • Save arif98741/636eeda31680c9001d7791f5978269ae to your computer and use it in GitHub Desktop.
Save arif98741/636eeda31680c9001d7791f5978269ae to your computer and use it in GitHub Desktop.
<?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