Forum Replies Created

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

    (@sjlink39)

    Yes, and global $wpdb is called in searchform.

    Thread Starter sjlink39

    (@sjlink39)

    It is being run at the top of winery-results. Query Monitor plugin shows that both of the Select routines are being run with empty variables. I can change it to hardcoding the variables and the Piedmont(NC) region displays nicely.

    Thread Starter sjlink39

    (@sjlink39)

    PHP 7.4, but it runs through until the last one. Apparently not picking up any of the parameters. Even at the end, it gets $regionst as empty.

    	<?php 
    			$winename = $_GET['winename'];
    			$cityst = isset( $_GET['cityst'] ) ?? '-select-';
    			$regionst = $_GET['regionst'];
    			if($winename <> '') {
    				$winerys = $wpdb->get_results("SELECT * FROM Wineries WHERE Name LIKE '%".$winename."%' ORDER By Name");
    			}
    			if($cityst <> '-select-') {
    				$citypos = strlen($cityst)-5;
    				$st = substr($cityst,$citypos,2);
    				$city = substr($cityst,0,$citypos-3);
    				/*$city = 'Wilson';
    				$st = 'NC'; */
    				$winerys = $wpdb->get_results("SELECT * FROM Wineries WHERE City = '".$city."' AND State = '".$st."' ORDER By Name");
    			}
    			if($regionst <> '-select-') {
    				/*$citypos = strlen($regionst)-3;
    				$st = substr($regionst,$citypos,2);
    				$region = substr($regionst,0,$citypos-1);*/
    				$region = $regionst;
    				$st = 'NC';
    				$winerys = $wpdb->get_results("SELECT * FROM Wineries WHERE Region = '".$region."' AND State = '".$st."' ORDER By Name");
    			}'
    • This reply was modified 5 years, 8 months ago by bcworkz. Reason: code fixed
    Thread Starter sjlink39

    (@sjlink39)

    I tried your isset example and it didn’t retrieve the query variables. Then I tried the code below and it still doesn’t retrieve the variables. Then I took out the query_vars add filter and it still didn’t help.

    $winename = $_GET['winename'];
    			$cityst = $_GET['cityst'];
    			$regionst = $_GET['regionst'];

    Maybe I set up the isset wrong – $cityst = isset( $_GET['cityst'] ) ?? '-select-';

    Help!

    Thread Starter sjlink39

    (@sjlink39)

    I have added

    function wwp_custom_query_vars_filter($vars) {
        $vars[] = 'winename';
    	$vars[] = 'cityst';
    	$vars[] = 'regionst';
    	$vars[] = 'Search';
        return $vars;
    }
    add_filter( 'query_vars', 'wwp_custom_query_vars_filter' );

    to functions.php

    Thread Starter sjlink39

    (@sjlink39)

    I have the code

    $winename = get_query_var( 'winename', '' );
    			$cityst = get_query_var( 'cityst', '-select-' );
    			$regionst = get_query_var( 'regionst', '-select-' );
    			if($winename <> '') {
    				$winerys = $wpdb->get_results("SELECT * FROM Wineries WHERE Name LIKE '%".$winename."%' ORDER By Name");
    			}

    yet it is like get_query_var is not working since it never sets $winerys
    I installed the Query Monitor plugin and it indicates that $winerys is unknown

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