Click to See Complete Forum and Search --> : results from recordset help needed


damon2003
12-02-2003, 05:37 AM
Hi,
I have several textfields on a page where the user enters a product code number.On submit, the coresponding preducts are displayed on the next page. The SQL statement is straight forward: SELECT * FROM TABLE WHERE X = text1 OR X = TEXT2 ect.

At the moment, if the user enters 2 identical codes in 2 of the textfields, only one of these products will be dispayed on the next page. What I actually want is to display 2 of the same products if the user enters 2 identical codes,
how can this be done?
thanks a lot

kedrhodes
12-02-2003, 12:45 PM
It sounds like you have a form that is built to ask the db for the content that the form supplies. If you want the db to display more than one of the same thing you will need to loop the query.

This concept would loop through the db and pull ALL the products with that ID. If you wanted to display ONLY 2 (or however many the form is requesting) you would have to count your $vars with the same ID, and then limit the query to however many it came up with.

I hope that helps.

damon2003
12-03-2003, 11:17 AM
Hi,
thanks alot,
will try this,
but is there no easier way than this? Is there not a way to modify the SQL in someway to perform the same function?
thanks

kedrhodes
12-04-2003, 01:17 PM
I don't know what your table looks like for that product, but if EACH product as a unique ID appointed my your DB you could ask the db for that instead of the product code. You will still have to loop though. The main reason you are only getting one result is the fact that the db will only print the first one it comes to with out a loop.

I hope that helps. Happy SQLing!