Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Querying a Query Table?

Author  Topic 

tchague
Starting Member

5 Posts

Posted - 2010-11-16 : 15:55:20
I'm not sure if what I'm trying to achieve here is possible, and I'm new to SQL so please bare with me....

I'm building a database powered website, and the website has a review section which is full of reviews for outdoor equipment. Therefore I've got a review tables with all my reviews in. Upon opening the reviews page a select query selects the review image, rating and name and displays them in table.

Now here comes the complicated bit..... From the table I want to some how click the review name/title and it query the database and open up a new page with the review on it itself along with the review image, rating, price and a few other details.


Hope someone can help me out, or point me in the right direction. Thanks.

TimSman
Posting Yak Master

127 Posts

Posted - 2010-11-16 : 15:57:15
I'd say you would have to have an underlying value for each displayed name, and pass that back to the database, then have the database pull whatever data you need based on that.

That's how I have always done it.
Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2010-11-16 : 15:57:20
Seems pretty straight forward. What are you having trouble with?

-Chad
Go to Top of Page

tchague
Starting Member

5 Posts

Posted - 2010-11-16 : 16:01:30
Here's the result page for my query: http://www.mroutdoors.co.uk/database/database/db_management/product_info/reviews/

From this i want to be able to some how select the review, which will take me to another page eith the review itself on and few other bots of info.

But I haven't a clue where to start.
Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2010-11-16 : 16:03:03
Add a hyperlink column that passes the ReviewID in the querystring.

-Chad
Go to Top of Page

tchague
Starting Member

5 Posts

Posted - 2010-11-16 : 16:06:25
Thanks, that makes sense. Know of any tutorials or examples on something about this?

I just need something to start me off, as I'm a complete novice with SQL. Thanks guys.
Go to Top of Page

TimSman
Posting Yak Master

127 Posts

Posted - 2010-11-16 : 16:15:47
Do you need help writing the query? Or need help configuring the hyperlink column?
Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2010-11-16 : 16:16:39
Are you using ASP.Net for the page?

If so a Bing search should provide many examples. Well, actually a Bing search will likely provide many examples regardless of what you are using. I would personally do it in ASP.Net, and use a GridView, which has a column type of HyperlinkColumn. It is pretty easy.

-Chad
Go to Top of Page

tchague
Starting Member

5 Posts

Posted - 2010-11-16 : 16:16:54
.... Both, would appreciate your help. :)
Go to Top of Page

TimSman
Posting Yak Master

127 Posts

Posted - 2010-11-16 : 16:54:36
For the query, you wuold ahve to provide information about the table(s) involved, namely the columns and data types.

For setting up the gridview, google "gridview hyperlink column". That would be a good start.
Go to Top of Page

tchague
Starting Member

5 Posts

Posted - 2010-11-16 : 18:44:36
I'm not using gridview or asp.net, instead I've got a hyperlink column, and each review has a cell with the following in it:
<a href="review.php?id={$review['id']}">NAME OF PRODUCT</a>

So when I click the name of the product it takes me to another page where the actual detailed review will be.

On the detailed review page, i need to check $_GET['id'] for the ID of the desired review, and run an SQL query to pull all the necessary data for just that review. However I'm having difficulty writing up the code to do this. (here's what I've got up to: http://www.mroutdoors.co.uk/database/database/db_management/product_info/reviews/). Thanks.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-16 : 19:26:25
why are we not asking him to just call a sproc?

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2010-11-16 : 20:41:12
We need to know your schema to help you write the query.


-Chad
Go to Top of Page
   

- Advertisement -