Forum Moderators: coopster
Here is my problem:
I have 2 tables in my DB. One table holds Sponsor Name and there ID number. The other table holds a list of tournaments and the ID number of the Sponsor of that tournament.
Ok, here is where I get lost. I am able to pull the tournaments from the DB and list them, but since I am storing the sponsor's ID number and not the sponsor's name in the tournament table, you see the number in the list and most users will not know the sponsor based on there ID number. What I need to do is, when I pull the tournament list from the DB, when echoed, I need to replace the Sponsor's ID number with the actual sponsor's name. So.......when echoing out the tournament list, the code needs to stop echoing, call the Sponsor table to get a list of the sponsors name and id numbers, then replace the id number with the name, Then continue echoing.
I am not sure how to do this.
Any suggestions on how to do a replace? Basically, I have a list of Sponsors being pulled from the DB and a list of Tournaments from the DB. Tournaments and Sponsors are added all the time, so hard coding a switch of names won't work, as the code should be dynamic.
Tables:
_sponsors (sid,sname)
_items (item,sid)
SELECT i.item,s.sname FROM _sponsor s, item i WHERE i.sid=s.sid
this query will select sponsor name from sponsor table and other data from items table
Recommendation: google MYSQL JOINTS and study them they are very handy