I'm trying to convert mysqli to PDO:
$product_id = $_GET['p'];
$product_query = "SELECT * FROM products,categories WHERE product_cat=cat_id AND product_id BETWEEN $product_id AND $product_id+3";
$run_query = mysqli_query($con,$product_query);
if(mysqli_num_rows($run_query) > 0){
while($row = mysqli_fetch_array($run_query)){
$pro_id = $row['product_id'];
$pro_cat = $row['product_cat'];
$pro_brand = $row['product_brand'];
$pro_title = $row['product_title'];
$pro_price = $row['product_price'];
$pro_image = $row['product_image'];
$cat_name = $row["cat_title"];
my attempt was not working, my issue is i'm not sure what is the equivalent of the mysqli_num_rows to PDO: the output should get a a product between a similar category list to show as related products for the ecommerce website
$query = $connect->prepare("SELECT * FROM product WHERE prd_cat = cat_id AND prd_id BETWEEN :product_id AND :product_id+3");
$query->execute(['product_id' => $_GET['p']]);
while ($row = $query->fetchAll()){
$pro_id = $row['prd_id'];
$pro_cat = $row['prd_cat'];
$pro_brand = $row['prd_brand'];
$pro_title = $row['prd_name'];
$pro_price = $row['prd_price'];
$pro_image = $row['prd_image'];
$cat_name = $row["cat_title"];
echo "
appreciate if anyone can help, I'm still trying to learn php and mysql, but I've read that PDO function to databases is better than mysqli.