Jump to content

Recommended Posts

Hey Guys im confused on this..

 

i have 2 tables

1 that is for the client that store the coupons and values

2 is the master list that  has all the coupons

So basically i show all the coupons from the master Databse and the members clicks add to his Album (Like a shopping cart)

 

So database members

MYID
UserID
CouponID    
DateIn    
Visible    
Precieux    
QTY_Visible    
QTY
CName    
Barcode    
Rebate    
Exp

Database Coupon_list

id
product_name    
product_desc    
product_code    
product_date_exp    
product_user    
product_image        
product_image_thumb    
product_status    
product_qty    
product_folder    
product_cat    rop    
product_type
product_month    
Recherche_Nom    
ImgType        
product_barcode    
master        
product_comp
product_rebate    
IsEditable    
 

SO i linked the both together and i need to have a search .this is what i did

 

  if(preg_match("/^[0-9- a-zA-Z]+/", $_POST['name'])){
      
  $name=$_POST['name'];


  $searchterms=preg_replace("/'/", "\'", $name);

  SELECT* FROM MyAlbum 
  INNER JOIN Coupon_list ON MyAlbum.CouponID=Coupon_list.id 
  WHERE MyAlbum.UserID = $Session 
  AND product_cat LIKE '%" . $searchterms .  "%'
  OR product_comp LIKE '%" . $searchterms ."%'  
  OR product_rebate LIKE '%" . $searchterms ."%' 
  OR id LIKE '%" . $searchterms ."%' 

But somehow i get all the Members results..not the members album...

 

i need to show the members album results not all the members

 

 

Please use the right terminology. You are talking about tables, not databases. Calling them "databases" is going to get people confused.

If you want information from a third table then you must be selecting from that third table. It won't magically appear without that.

ya i got it cause my AND was before the OR

 

$teamQuery3=mysqli_query($DBcon,"SELECT* FROM MyAlbum
    LEFT JOIN Coupon_list ON MyAlbum.CouponID =Coupon_list.id
    WHERE product_cat LIKE '%" . $searchterms .  "%'
    OR product_comp LIKE '%" . $searchterms ."%'
    OR product_rebate LIKE '%" . $searchterms ."%'
    OR MyAlbum.CouponID LIKE '%" . $searchterms ."%'
    AND MyAlbum.UserID = $Seesion");

 

 

cause i have a master table that conatains all the coupons. So the member scrolls all the coupons and if he has it he adds it to his album.

before i was duplicating the info in the members album..

 

now what i do is store the id of the master coupon in the MyAlbum database with the qty names....

 

 

 

I have no idea what you just said.

 

However, when using a mix of AND and OR in a WHERE clause, use parentheses to define the logic. For example

A AND B OR C

Do you mean

(A AND B) OR C

or do you mean

A AND (B OR C)

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.