469,323 Members | 1,198 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

Query strings

Hi, I'm Drew and I'm new here; and I could really use some help. I have a website in which I took offline because I found another host that will provide me with more space at a cheaper price. Before I temporarly took it offline to change domains, I decided I want to revamp the whole site, new layout, etc. Now I'll get to the question at hand. My website provides things such as news, sports, weather alot of stuff including a subdomain that features video sharing like Youtube. When I did my website in the past I used plain HTML, which is ok, but I've been using it for way to long and really want to change the method. I have rebuilt part of the site thus far using ASP, and with this ASP instead of having it like before, I.E. creating every page separtly, I want to have one page for every category. For example, when you go to your local network affiliate website their URLs look like this, theirsite.com/Global/Story.asp?S= or thiersite.com/Global/Category.asp?C= I want to do my site the same way, except without the /Global/ seperation. So for instance say you would come to my website and see a story about Bob eating a hamburger and that story was of some interest to you so you click on it and it would take you to Story.asp, then display the story you wanted and it would be displayed like this in the url mysite.com/story.asp?s=random numbers instead of using the method I've used before which would of looked like this mysite.com/news/bob_eating_a_hamburger.html

My question is, how do I go about doing this? I know how to create the main pages, I.E. story.asp, category.asp, etc. I just don't know how to get the stories, etc to diplay on the main pages. I'm using ASP and an access database.

I hope I haven't confused anyone, cause I think I just confused myself a little more. :-) Whatever help can be provided I will be so thankful with! I've looked everywhere and have asked on different forums, but no one answers. I have basic knowledge in ASP, PHP, HTML, HTM, and XML. So I really want to learn how to do this and advance a little more.

Thanks so much in advance!
Aug 5 '07 #1
3 1254
ilearneditonline
130 Expert 100+
My question is, how do I go about doing this? I know how to create the main pages, I.E. story.asp, category.asp, etc. I just don't know how to get the stories, etc to diplay on the main pages. I'm using ASP and an access database.
So let's start with the main page where you would be pulling from the database. I would suggest thinking about using a different db though, access isn't good for much of anything to complicated.

So on your main page you would have a link like...
[HTML] <a href="mysite.com/story.asp?s=1232345">The Story</a>[/HTML]

When clicked, this would take you to story.asp...
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim storyid
  3. Dim rs, db, query ' variables for db connection, recordset, and querystring 
  4. ' s represents the query string parameter
  5. storyid = Request.QueryString("s")
  6.  
  7. query = "SELECT storyid, storytitle, storydetails FROM t_stories WHERE storyid=" & s
  8. db = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=;"
  9. Set rs = Server.CreateObject("ADODB.Recordset")
  10.  
  11. rs.ActiveConnection = db
  12. rs.Source = query
  13. rs.CursorType = 0
  14. rs.CursorLocation = 2
  15. rs.LockType = 1
  16. rs.Open()
  17. %>
Hope that is enough to get you started.
Aug 5 '07 #2
Thank you so much! I have one last question, then I should be set.

How do I save the stories, in .txt files, regular HTM format, or do I write them in a table in the database? If I do write them in a text file and or HTM format, do I then create a table in the database that links to it so it then will open and display in the appropriate place?

Thanks again!
Aug 6 '07 #3
ilearneditonline
130 Expert 100+
Thank you so much! I have one last question, then I should be set.

How do I save the stories, in .txt files, regular HTM format, or do I write them in a table in the database? If I do write them in a text file and or HTM format, do I then create a table in the database that links to it so it then will open and display in the appropriate place?

Thanks again!
My example suggests that you are saving it to a database. You could check out the w3school tuturial on ADO. It has everything you need to write the code. I wouldn't use .txt or html files. You should also look into doing some caching to speed up your site.
Aug 6 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by theboss3 | last post: by
4 posts views Thread by Alistair | last post: by
6 posts views Thread by Martin Lacoste | last post: by
2 posts views Thread by Oliver Block | last post: by
12 posts views Thread by zwasdl | last post: by
13 posts views Thread by john | last post: by
3 posts views Thread by Nathan Guill | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.