• In my code $wpdb->get_var is not working and it always shows “Country is not available for delivery”. Please help. Here is my code.

    <form method="post" action="<?php $_SERVER["PHP_SELF"]; ?>">
                    Country:
                    <select name="country" id="country">
                        <option value="">Select Country</option>
                        <?php
                        global $wpdb;
                        $results = $wpdb->get_results("SELECT kcsc.country_fullname FROM KCS_country kcsc,wpws_woocommerce_shipping_zone_locations wszl where kcsc.country_code=wszl.location_code and wszl.location_type='country' order by wszl.location_code");
                        foreach ($results as $res) {
                            ?>
                            <option value="<?php echo $res2->country_fullname; ?>"><?php echo $res->country_fullname; ?></option>
                            <?php
                        }
                        ?>
                    </select>
                    <input type="submit" name="country_submit" value="Submit">
                </form>
            </div>
    
            <?php
            if (isset($_POST["country_submit"])) {
                global $wpdb;
                $country = $_POST['country'];
                $myrow2 = $wpdb->get_var("select wszl.location_code from wpws_woocommerce_shipping_zone_locations wszl,KCS_country kcsc where kcsc.country_code=wszl.location_code and kcsc.country_fullname='".$country."'");
                if ($myrow2){
                echo "Country is available for delivery";
               }
               else
                    echo "Country is not available for delivery";
            }
            ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘$wpdb->get_var is not working’ is closed to new replies.