Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter William1234

    (@william1234)

    Hi Briankeith68,

    I still can’t get the result.

    Example what is did “AND posts.post_title LIKE ‘%$searchVariable%'”

    Where the $searchVariable will get the input value from user.

    Thread Starter William1234

    (@william1234)

    Hi Tijmen,

    I did try see are the query get result or not in the code below

    $stores = $wpdb->get_results( $wpdb->prepare( $sql, $placeholder_values ) );
    
                if ( $stores  ) {
                    //echo $searchvalues;
                    $store_data = apply_filters( 'wpsl_store_data', $this->get_store_meta_data( $stores ) );
                }
                else{
                    echo "No result";
                }

    It show “No result”. Yes. Without wpsl_state the code also not work fine.

    Thread Starter William1234

    (@william1234)

    Hi Tijmen,

    I did try on the post the you suggested for me and apply to the SQL to search for the matches store name.

    $sql = apply_filters( 'wpsl_sql',
                               "SELECT posts.post_title AS store,
                                       post_state.meta_value AS state,
                                       posts.ID,
                                       ( %d * acos( cos( radians( %s ) ) * cos( radians( post_lat.meta_value ) ) * cos( radians( post_lng.meta_value ) - radians( %s ) ) + sin( radians( %s ) ) * sin( radians( post_lat.meta_value ) ) ) )
                                        AS distance
                                  FROM $wpdb->terms AS terms
                                  INNER JOIN $wpdb->term_taxonomy AS term_taxanomy ON term_taxanomy.term_id = terms.term_id
                                  INNER JOIN $wpdb->term_relationships AS term_relationships ON term_relationships.term_taxonomy_id = term_taxanomy.term_taxonomy_id
                                  INNER JOIN $wpdb->posts AS posts ON posts.ID = term_relationships.object_id
                            INNER JOIN $wpdb->postmeta AS post_lat ON post_lat.post_id = posts.ID AND post_lat.meta_key = 'wpsl_lat'
                            INNER JOIN $wpdb->postmeta AS post_lng ON post_lng.post_id = posts.ID AND post_lng.meta_key = 'wpsl_lng'
                            INNER JOIN $wpdb->postmeta AS post_state ON post_state.post_id = posts.ID AND post_state.meta_key = 'wpsl_state'
                                $cat_filter
                                 WHERE posts.post_type = 'wpsl_stores'
                                   AND posts.post_status = 'publish'
                                   AND post_state.meta_value='$states'
                                   AND terms.term_id='8' AND posts.post_title LIKE '%CAR CARE%'
                               "
                        );

    It show no result. But it show have record when execute this code is my database sql.

    I might urgent need your help. Please assist me on this.

    Appreciate much for your help.

    Thread Starter William1234

    (@william1234)

    Hi Tijmen..can you assist me on this ? Based on the query provide above..I could. it get the result based on the $searchvalues..
    If any mistake on my code..please advise me
    thanks

    Thread Starter William1234

    (@william1234)

    Hi Tijmen, I have been trying to find the solution on search by Store name in my query.

    I realize when I apply “LIKE” at the end of the query, it show no result.

    But I did try the query in my database. It able to get the record.

    Can you assist me on this ?

    $sql = apply_filters( 'wpsl_sql',
                           "SELECT posts.post_title AS store,
                                   post_state.meta_value AS state,
                                   post_lat.meta_value AS lat,
                                   post_lng.meta_value AS lng,
                                   posts.ID,
                                   ( %d * acos( cos( radians( %s ) ) * cos( radians( post_lat.meta_value ) ) * cos( radians( post_lng.meta_value ) - radians( %s ) ) + sin( radians( %s ) ) * sin( radians( post_lat.meta_value ) ) ) )
                                    AS distance
                              FROM $wpdb->terms AS terms
                              INNER JOIN $wpdb->term_taxonomy AS term_taxanomy ON term_taxanomy.term_id = terms.term_id
                              INNER JOIN $wpdb->term_relationships AS term_relationships ON term_relationships.term_taxonomy_id = term_taxanomy.term_taxonomy_id
                              INNER JOIN $wpdb->posts AS posts ON posts.ID = term_relationships.object_id
                        INNER JOIN $wpdb->postmeta AS post_lat ON post_lat.post_id = posts.ID AND post_lat.meta_key = 'wpsl_lat'
                        INNER JOIN $wpdb->postmeta AS post_lng ON post_lng.post_id = posts.ID AND post_lng.meta_key = 'wpsl_lng'
                        INNER JOIN $wpdb->postmeta AS post_state ON post_state.post_id = posts.ID AND post_state.meta_key = 'wpsl_state'
                            /*$cat_filter*/
                             WHERE posts.post_type = 'wpsl_stores'
                               AND posts.post_status = 'publish'
                               AND post_state.meta_value='$states'
                               AND terms.term_id='8'
                               AND posts.post_title LIKE '%$searchvalues%'"
    Thread Starter William1234

    (@william1234)

    Hi Tijmen,

    Yes.

    I found 2 problem now.

    1) I realize something that before this plugin is updated, i can simple retrieve State column from each record to the drop down. But now I having problem on retrieve the state column as an option for my drop down.

    2) I can’t find a solution that only show the result based on the store name that I insert into the input field.

    Thanks for the assist.

Viewing 6 replies - 1 through 6 (of 6 total)