Jump to content

Search from 1 Database linked to another..


techker

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

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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....

 

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.