473,466 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Drawing meta tags from a database in an asp page

114 New Member
I want to draw out records from the database, and use them in my meta tags. I only want to use one record, which is called "TITLE", and i want to use this in the "title", "keywords", and "description", in other word the content of all 3 is "TITLE"

I have page called "view.asp" whose relevant code is as below. The meta tags are in "inc.header.asp" file.


Expand|Select|Wrap|Line Numbers
  1. <!--#include file="inc_header.asp"--> 
  2.  
  3.     <% Dim SQL, RS, ID, TITLE, CONTENT, SUMMARY, POSTED, ALLOW_C, ALLOW_V, UPDATED, MESSAGE, VOTED, ALLOW_V_MAIN, _
  4.            ALLOW_C_MAIN, NID, AUTHOR, CATEGORIES, AID, USE_VIEW, NIMAGE
  5.           Dim CCOUNT, C_ID, C_NAME, C_EMAIL, C_COMMENT, C_DATE, C_SUBJECT, C_M_ID, C_ALLOW_E, C_CITY, C_COUNTRY, _
  6.               RCOUNT, RID, RTITLE, ACOUNT
  7.  
  8.  
  9.     NID   = Trim(Request.QueryString("ID"))
  10.     VOTED = Trim(Request.Cookies("NEWS_ARTICLE_" & NID))    
  11.     MEMBER_ID = Trim(Session("PMMS_ID"))    
  12.     IF Trim(Session("PMMS_IN")) = "True" THEN blLOGGED_IN = True    
  13.  
  14.     IF IS_VALID_ID(NID) THEN
  15.  
  16.         Call OPEN_DB() 
  17.  
  18.         SQL = "SELECT fldA_V, fldA_C FROM nm_tbl_settings WHERE ID = 1"
  19.         Set RS = Server.CreateObject("ADODB.Recordset")
  20.         RS.LockType   = 1
  21.         RS.CursorType = 0
  22.         RS.Open SQL, MyConn    
  23.              IF NOT RS.EOF THEN
  24.                  ALLOW_V_MAIN = trim(RS("fldA_V"))
  25.                 ALLOW_C_MAIN = trim(RS("fldA_C"))
  26.              END IF
  27.         RS.Close        
  28.  
  29.         SQL = "UPDATE nm_tbl_news SET fldVIEWS = fldVIEWS + 1 WHERE ID = " & NID
  30.         MyConn.Execute(SQL)
  31.  
  32.         SQL = "SELECT fldTITLE, fldCONTENT, fldSUMMARY, nm_tbl_news.fldACTIVE AS ACTIVE, fldAID, fldPOSTED, fldEXPIRES, nm_tbl_news.fldIMAGE AS NIMAGE, fldALLOW_COMMENTS, fldALLOW_VOTING, fldCREATED, fldUPDATE, nm_tbl_agent.fldNAME AS ANAME, nm_tbl_news.fldAID AS AID, fldUSE_VIEW FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE = 1) AND nm_tbl_news.ID = " & NID ' { AND (Now() - {GetDate()} BETWEEN fldPOSTED AND fldEXPIRES)) }
  33.         response.write vbNewLine & "<!-- SQL: " & SQL & " -->" & vbNewLine
  34.         Set RS = Server.CreateObject("ADODB.Recordset")
  35.         RS.LockType   = 1
  36.         RS.CursorType = 0
  37.         RS.Open SQL, MyConn    
  38.              IF NOT RS.EOF THEN
  39.                  TITLE   = trim(RS("fldTITLE"))
  40.                 CONTENT = trim(RS("fldCONTENT"))
  41.                 SUMMARY = trim(RS("fldSUMMARY"))
  42.                 POSTED  = trim(RS("fldPOSTED"))
  43.                 ALLOW_C = trim(RS("fldALLOW_COMMENTS"))
  44.                 ALLOW_V = trim(RS("fldALLOW_VOTING"))
  45.                 UPDATED = trim(RS("fldUPDATE"))
  46.                 AUTHOR  = trim(RS("ANAME"))
  47.                 AID     = trim(RS("AID"))
  48.                 USE_VIEW= trim(RS("fldUSE_VIEW"))
  49.                 NIMAGE  = trim(RS("NIMAGE"))                
  50.              ELSE   
  51.                 MESSAGE = MESSAGE & "<li />This article is currently not available."
  52.              END IF
  53.              response.write vbNewLine & "<!-- SQL: " & SQL & " -->" & vbNewLine
  54.         RS.Close 
  55.  
  56.         CONTENT = ReplaceAuthorTokens(AID, CONTENT)        
  57.         CATEGORIES = GET_CATES(NID)
  58.  
  59.         ' Get settings
  60.         Dim DATE_F
  61.         DATE_F = GET_SETTINGS(False, "fldDATE_F")        
  62.  
  63.         TITLE = PROCESS_SHORTCUTS(False, TITLE)
  64.         CONTENT = PROCESS_SHORTCUTS(False, CONTENT)
  65.         SUMMARY = PROCESS_SHORTCUTS(False, SUMMARY)
  66.  
  67.     ELSE
  68.  
  69.       MESSAGE = MESSAGE & "<li />No article has been found."
  70.  
  71.     END IF
  72.     %>
and this is the relevant part of the "inc.header.asp" code below

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <!--#include file="config.asp"-->
  4. <!--#include file="inc_api.asp"-->
  5. <% Response.Buffer = True %>
  6.  
  7. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  8. <html>
  9. <head> 
  10. <% 
  11. title = "article title" %>
  12. <title> rs("TITLE")</title>
  13. <%
  14. meta_description = "the description goes here" %>
  15. <meta name="description" content="rs("fldTITLE")">
  16. <%
  17. meta_keywords = "this, is, the, keyword, section," %> 
  18. <meta name="keywords" content="RS("fldTITLE")">
However, the above code doesn't pull out the field "title" and display it, when i check the page on the world wide web. When i check the code using "view source" this is what it says:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head> 
  3.  
  4. <title> rs("TITLE")</title>
  5.  
  6. <meta name="description" content="rs("fldTITLE")">
  7.  
  8. <meta name="keywords" content="RS("fldTITLE")">
So what am i doing wrong? i think i have the code in the "inc.header.asp" messed up somewhere. ~Any help appreciated.
Oct 8 '07 #1
4 1723
karen987
114 New Member
Sorry i forgot to add, I'm not html literate, so i'd appreciate it if anyone could show me exactly what to put on both pages
Oct 8 '07 #2
karen987
114 New Member
actually i've changed the format now, i no longer need the inc.header.asp page,

so i'm going to put the code at the top of the view.asp page, which is like this, however, it's not picking up the Title. I want the title of the article to be the title of the page, and the meta tags content for description and keywords. The code is as above, so where do i put the

the code to view.asp is in the first post i posted in this thread


Expand|Select|Wrap|Line Numbers
  1. <% 
  2. title = "article title" %>
  3. <title><%=title%></title>
  4. <%
  5. meta_description = "the description goes here" %>
  6. <meta name="description" content="<%=meta_description%>">
  7. <%
  8. meta_keywords = "this, is, the, keyword, section," %> 
  9. <meta name="keywords" content="<%=meta_keywords%>">
Oct 8 '07 #3
jhardman
3,406 Recognized Expert Specialist
Sorry i forgot to add, I'm not html literate, so i'd appreciate it if anyone could show me exactly what to put on both pages
There are some good ways to become HTML literate. It is generally considered an easy-to-learn language. It really isn't a programming language, it is just plain text instruction for how to format text and display web pages. Here is a good tutorial. If you are planning to do all the work of building and maintaining the site, it might be a good idea to find a good reference book. Most public libraries have a few, and every bookstore and computer supply store has several to chose from.

Jared
Oct 9 '07 #4
karen987
114 New Member
I will try that, Jared, thanks for the tips.
Oct 11 '07 #5

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

Similar topics

19
by: Christian Hvid | last post by:
Hello groups. I have a series of applet computer games on my homepage: http://vredungmand.dk/games/erik-spillet/index.html http://vredungmand.dk/games/nohats/index.html...
24
by: Day Bird Loft | last post by:
Web Authoring | Meta-Tags The first thing to understand in regard to Meta Tags is the three most important tags placed in the head of your html documents. They are the title, description, and...
2
by: laredotornado | last post by:
Hello, How effective are META tags when used as tools to classify a page's content for a search engine? The common one is <META NAME="Keywords" CONTENT="tropical fish,fish,tetras,guppies"> ...
6
by: Fred Nelson | last post by:
Hi: I'm developing a new C# Web App and I'm hoping to find a way that I can dynamically generate meta tags for the search engines at the page level. (I want to do this so that I can have someone...
16
by: Edward | last post by:
Hi All, I am having huge problems with a very simple dotnet framework web page (www.gbab.net/ztest3.aspx) , it does NOT render correctly under Apple's Safari. The DIV's do not align amd float as...
4
by: bashetty | last post by:
Well its a strange problem i have, some of you might already faced it and have a solution. I have to maintain a set of unique "search key words" in meta tags for each content page in my site. With...
21
by: karen987 | last post by:
I have a news website, with asp pages. It has publishing software which allows you to add articles in a database, and then calls them up from links etc. I have added dynamic meta tags in 2 parts. The...
2
by: runway27 | last post by:
i have a registration page which is a self submitting form <form action="<?php echo $_SERVER; ?>" method="POST" id="test2" name="registrationform"> where in a user fill a form, after the data...
3
by: Jordan S. | last post by:
I'm looking to localize an ASP.NET Web application for English, Spanish, and French (fr-CA), and was just considering the possibility of localizing the meta tags (e.g., keywords, title, and...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.