Page 1 of 1

ignore a record if = 0 not working and alternatives

Posted: Mon Oct 08, 2012 7:39 am
by jonnyfortis
i have a product table and a stock table aswell as a few more. to show the item is out of stock there are two ways. i would like to know both so can decide.

one would be to just the size that has run out just not have it in the list. (this is the easier) i have the code but cant get it to work

SELECT *
FROM poochieProd, poochieCat, poochieSizes, poochieStock
WHERE poochieProd.CatID = poochieCat.CatID AND poochieProd.ProdID = poochieStock.ProdID AND poochieSizes.SizeID = poochieStock.sizeID AND poochieProd.ProdID = var1 AND poochieStock.sold !=1

then if a value of 1 is in the poochieStock.sold it will not show.

this isnt however working for me.

the other is to have the words "soldout" nest to the size that is sold out. With this option however i would need to stop the user selecting this size with either an alert say please choose another size or if they do still choose this size send the to a contact page...

any help would be greatly appreciated

Re: ignore a record if = 0 not working and alternatives

Posted: Mon Oct 08, 2012 9:45 am
by Christopher
jonnyfortis wrote:SELECT *
FROM poochieProd, poochieCat, poochieSizes, poochieStock
WHERE poochieProd.CatID = poochieCat.CatID AND poochieProd.ProdID = poochieStock.ProdID AND poochieSizes.SizeID = poochieStock.sizeID AND poochieProd.ProdID = var1 AND poochieStock.sold !=1

then if a value of 1 is in the poochieStock.sold it will not show.

this isnt however working for me.
The first question is why this is not working? What happens is you do just:
SELECT *
FROM poochieProd, poochieCat, poochieSizes, poochieStock
WHERE poochieStock.sold !=1
jonnyfortis wrote:the other is to have the words "soldout" nest to the size that is sold out. With this option however i would need to stop the user selecting this size with either an alert say please choose another size or if they do still choose this size send the to a contact page...

any help would be greatly appreciated
There are many ways to do this. If you are using a <select> then you could have Javascript check for the sold-out sizes and display the message (and not allow those sizes to be selected). Or you could use PHP to mark them as sold-out in the select and give them a special value like -1 so they will be ignored with the form is submitted. You could also show the sizes as radio buttons and use PHP to not generate a radio button for the sold-out sizes.

Re: ignore a record if = 0 not working and alternatives

Posted: Mon Oct 08, 2012 1:36 pm
by jonnyfortis
> Or you could use PHP to mark them as sold-out in the select and give them a special value like -1 so they will be ignored with the form is submitted.

this sounds like what i want to do. Any guidance on how this is done?

thanks