Jump to content

Using PHP to pull information from MySQL Database while excluding.


Recommended Posts

Hi,

 

Currently, I have this website: http://www.kayberry.com.

 

Brief Overview:

It has a product catalog.  The site was originally programmed by someone else and I am taking over for this project.  There are 2 types of users in for this site: end user, retailer which they can be floral, distributor or both.  Each type of user sees specific information.  Under Floral there are only 17 products.

 

All the information about the products gets pulled from the same table in the database called (kb_products) which contains the columns: id, name, code, product_categories, styles, price, thumb_image, medium_image, large_image, information, personable, active, total_purchased. Now from what I can see the important ones to keep in mind are: code and product_categories.

 

All information about the users is pulled from a table in the database called (kb_users) which contain the important columns: type, is_floral, is_distributor.

 

In the backend of the site when you create a user there is a check box for Floral and Distributor that sets the users as Floral, Distributor or both.

 

 

The Issue:

All products under Floral have the “code” column with the numbers always end in 84 (For Example: 13084 or 14784. There are numbers like 08420 that do not fall under Floral.  In addition, under “product_categories” has it set to 3, both columns like I said are in the kb_products table.

 

The problem is the search.

 

For the End User there isn’t a problem when I search for 84 I get all the other products besides Floral products.

 

When I login as a retailer that isn’t a marked as Floral I can search 84 and see all 84’s that are in the product_categories column.  What I need to do is exclude all products that end in 84 that are not marked as Floral.  The same thing happens with New Items and Popular items but if I figure out how to remove 84 from the search for those that are not marked as floral I should be able to figure this out.

 

The source code is attached.  Just convert the file type to PHP

 

I believe the search starts at line 203.

 

On line 213 there is a piece of code !is_logged_in(‘3’) but I do not believe this does anything because is_logged_in is equal to the type which has no # 3 in the database.

 

On line 225 I tried adding:

 

elseif (!is_logged_in('2') && $category_id == 3)

{$sql .= 'AND code REGEXP "(code < 13084 AND code > 14784)"'; }

 

But no dice.

 

Any help would be appreciated.

 

Thanks,

 

-Mike

 

 

[attachment deleted by admin]

Is there anyone that can at least let me know if my syntax is correct.  I am trying to pull from a table in the MySQL database called code which contains the information and exlude the numbers that end in 84.

 

Thanks

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.