I am trying to insert statement in [share] table and update statement in [balance] table if balance is greater than or equal to 75 in balance table, But it is going to the else statement always, even though it meets necessary condition balance>=75
Following is my code:
<?php
if (isset($_POST['submit'])) {
$site = htmlspecialchars($_POST['site']);
$me=$current_user->user_login;
$today = date('Y-m-d');
$me=$current_user->user_login;
$table_balance = $wpdb->prefix . "balance";
$result = $wpdb->get_results(
"SELECT Balance FROM $table_balance WHERE User= '$me'"
);
if ($result && mysql_num_rows($result)>=75) {
$random = uniqid();
$table_share = $wpdb->prefix . "share";
$wpdb->insert( $table_share, array(
'id' => $random,
'purchasedate' => $today,
'purchasevalue' => 75,
'offervalue' => 0,
'status' => Active,
'user' => $me,
'monthlyearnings' => 2,
));
$sum=75;
$table_balance = $wpdb->prefix . "balance";
$wpdb->update(
"$table_balance SET Balance=Balance-$sum WHERE User = '$me'"
);
echo "Purchased made successfully";
exit();
} else {
echo "sorry!you dont have required amount.pls add required amount";
}
?>