Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiversion Page System (SQL Problem)

Status
Not open for further replies.

ralphiooo

Programmer
Oct 23, 2005
64
GB
Hi, I've got the following tables set up:

tbdPages:
- ID
- fldTitle
- fldContent

tbdLookupVersion
- ID
- fldVersionID

tbdVersion
- ID
- fldPageID
- fldVersionID

Basically the pages table is the content for the website and the version table stores information on which page is for which version. This allows me to create a whole set of new pages for a different version. I have setup a global file with a variable vbgvntVersionID which is the id of the current version running on the site. I have the admin panel setup perfectly but what I need to do is setup an sql query so that if you pass a page id in via the querystring (on the front end of the site) it returns a page (if it exists - ie applies to the current version of the website and has the same id as the one passed in).

I'd appreciate if someone could help. Thanks
 
Hi, I thought I'd help out and provide some sample data:

Code:
tbdPages:
| ID | fldTitle | fldContent |
  1     Home       Welcome...
  2     Contact    Contact...
  3     About      About...

tbdLookupVersion:
| ID | fldVersion (typo above) |
  1     0.1
  2     0.2
  3     0.3

tbdVersion
| ID | fldPageID | fldVersionID
  1       1           0.1
  2       1           0.2
  3       1           0.3
  4       2           0.3
  5       3           0.3

Therefore if vbgvntVersionID = 0.3 then any page would be returned in the sql query (based on the id passed in the querystring) as a record exists for each page in the tbdVersion table, but if vbgvntVersionID = 0.1 or 0.2 and the id passed in the querystring was 1 then it would return the home page but if the id was 2 or 3 then it would return nothing as no record exists in the tbdVersion table matchin that id and version.

Hope that makes things clear. Thanks
 
your data looks wrong, tbdVersion.fldVersionID should have id values, not version values

this is what i think you need if your data was as originally described --
Code:
select tbdPages.fldTitle
     , tbdPages.fldContent
  from tbdVersion
inner
  join tbdPages
    on tbdVersion.fldPageID = tbdPages.ID
 where tbdVersion.fldPageID 
         = [i]querystring pageID[/i]
   and tbdVersion.fldVersionID 
         = [i]variable vbgvntVersionID[/i]

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top