techker Posted November 5, 2018 Share Posted November 5, 2018 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 Quote Link to comment Share on other sites More sharing options...
requinix Posted November 5, 2018 Share Posted November 5, 2018 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. Quote Link to comment Share on other sites More sharing options...
techker Posted November 5, 2018 Author Share Posted November 5, 2018 sorry, i only need 2 tables and search in my first that links the second to view the coupons by id Quote Link to comment Share on other sites More sharing options...
Barand Posted November 5, 2018 Share Posted November 5, 2018 You have shown us the content of two tables members coupon_list Your query uses two tables MyAlbum coupon_list so I haven't a clue what you are really trying to do as your post makes no sense. Quote Link to comment Share on other sites More sharing options...
techker Posted November 5, 2018 Author Share Posted November 5, 2018 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.... Quote Link to comment Share on other sites More sharing options...
Barand Posted November 5, 2018 Share Posted November 5, 2018 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) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.