Forum Moderators: open

Message Too Old, No Replies

mysql question

Need urgent help with this please!

         

help_me

6:29 am on Apr 28, 2008 (gmt 0)

10+ Year Member



Hey, this is a bit difficult to explain, but I have a database and my web site inserts entries with a user name e.g. when a user clicks "add" it will add the following in to the database: user name, title, price, unit id. Since every time the user clicks "add" it adds a new row with their user name I have done a query and a while loop that supplies me with all the "unit id's" of the rows, now what I need help with is how do I use the array of the "unit id's" to do another query to get information about the items in another table in the database where all the information is stored about the items. If anyone could help me it would be much appreciated, if you would like me to go in to more detail or don't quite get what I am trying to do, please reply and ask for further information.

Thanks

Aiden

dreamcatcher

8:19 am on Apr 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld Aiden. :)

As this is database specific, I have moved it to the database forum for you.

dc

help_me

8:25 am on Apr 28, 2008 (gmt 0)

10+ Year Member



Hey, thanks, sorry I am new to this website and it's a tad hard to navigate on this site when your in a hurry.

coopster

8:48 pm on Apr 28, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You can loop through this initial result set using server-side code and querying the database for each row again, but an alternative would be to join the tables together and execute a single query, returning all the data in a single query and then process the result set.

help_me

5:37 am on Apr 30, 2008 (gmt 0)

10+ Year Member



Thanks for that, I sorted that problem yesterday, but thanks anyway. Maybe you could help me with my next problem.

I have a row that I have set to have it's values inserted as follows: 1:whole:unit, I have exploded the row so it now reads "1 whole row". What I am wanting to do is to see if any of the second variables in the rows match e.g. if 2 rows in the database have "1:whole:row" in it I want to write a script that finds matching second variables e.g. "whole" in this instance ($string[1]) and then add the first variables ($string[0]) together, so "1:whole:unit" would become "2 whole units" once the script is finished processing.

If you could help me with this it would be much appreciated.

Cheers

Aiden