Answers for "php rowcount"

PHP
2

sql row count php pdo

<?php
/* Delete all rows from the FRUIT table */
$del = $dbh->prepare('DELETE FROM fruit');
$del->execute();

/* Return number of rows that were deleted */
print("Return number of rows that were deleted:\n");
$count = $del->rowCount();
print("Deleted $count rows.\n");
?>
Posted by: Guest on July-31-2020
1

number of rows in a mysql table pdo

//Instantiate the PDO object and connect to MySQL.
$pdo = new PDO(
    'mysql:host=127.0.0.1;dbname=my_database',
    'username',
    'password'
);
 
//The COUNT SQL statement that we will use.
$sql = "SELECT COUNT(*) AS num FROM users";
 
//Prepare the COUNT SQL statement.
$stmt = $pdo->prepare($sql);
 
//Execute the COUNT statement.
$stmt->execute();
 
//Fetch the row that MySQL returned.
$row = $stmt->fetch(PDO::FETCH_ASSOC);
 
//The $row array will contain "num". Print it out.
echo $row['num'] . ' users exist.';
Posted by: Guest on June-06-2020
-1

mysql rowcount php

<?php

$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $link);

$result = mysql_query("SELECT * FROM table1", $link);
$num_rows = mysql_num_rows($result);

echo "$num_rows Zeilen\n";

?>
Posted by: Guest on November-15-2020

Browse Popular Code Answers by Language