• Hi. I’m not very good with PHP but I’m learning so can someone point me in the right direction with this? I’ve been trying to get this working for weeks now.

    I have users that enter their zip code and then select a pre-determined type of business from a drop down option box during registration. This info is recorded to the wp_usermeta table in the database.

    Then when someone enters a zip code and if there is any data in the database, that business info will be displayed. The plugin is working for this. What I am trying to get at is if there is no business that has registered for a selected option within the entered zip code, then it will display (along with the other businesses in the database) a line that reads something like “Claim this Spot”

    So it would look like:

    Hardware????????????? Smith Hardware
    Flowers??????????????? Johnson Flowers
    Construction???????? Claim this Spot (This links to registration page)

    The code I have so far is:

    function list_business_info_register_shortcodes()
    {
    add_shortcode('list-business-info', 'list_business_info_function');
    }
    add_action( 'init', 'list_business_info_register_shortcodes');
    
    function list_business_info_function()
    {
    if (isset($_POST['zip']))
    $zip = $_POST['zip'];
    $businfo = '';
    
    $result = mysql_query("SELECT user_id FROM wp_usermeta WHERE meta_key='rpr_9-digit_zip_code' AND meta_value=$zip");
    
         while ($row = mysql_fetch_array($result))
         {
         $userid = $row['user_id'];
         $bustype = mysql_query("SELECT meta_value FROM wp_usermeta WHERE meta_key='rpr_business_type' AND user_id=$userid");
    
         	while ($businesstype = mysql_fetch_array($bustype))
    	{
    	$businesstypevalue = $businesstype['meta_value'];
         	$businfo .='<tr><td>';
         	$businfo .= $businesstypevalue;
         	$businfo .='</td><td>';
         	$businfo .='Name of Business';
         	$businfo .='</td></tr>';
    	}
    
         }
    return $businfo; 
    
    }

    I’ll add some code to get the “Name of Business” part later. Can someone give me some direction?

    Thanks so much.

    [Moderator Note: No bumping. If it’s so urgent that you cannot wait longer than 1 hour on a free, volunteer-staffed forum,, then hire someone instead.]

  • The topic ‘Please Help – Trouble with new plugin – – List Zip Group Info’ is closed to new replies.