• I want to count the amount of rows returned by the mysql query. but it always returns 0. how do i do this?

    $sDate = $_POST['selectedDate'];
    $sTitle = $_POST['selectedTitle']; 
    
    $result = $wpdb->get_results( "SELECT * FROM " . $candvAdmin_availability_table_name . " WHERE car = '" . $sTitle . "' AND dateOfBooking '" . $sDate . "'" );
    
    $countResults = count($result);

    if ($countResults == 0){
    echo “ok”;
    }else{
    echo “no”;
    }

Viewing 1 replies (of 1 total)
  • Thread Starter jimmyt1988

    (@jimmyt1988)

    $result = $wpdb->get_var($wpdb->prepare( “SELECT COUNT(*) FROM ” . $candvAdmin_availability_table_name . ” WHERE car = ‘” . $carChoice . “‘ AND bookingDate = ‘” . $bookingDate . “‘;” ));

Viewing 1 replies (of 1 total)
  • The topic ‘count entries in database where bla = something and ble = something’ is closed to new replies.