Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Naming an output file
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Naming an output file

 Post Reply Post Reply
Author
l15aRd View Drop Down
Groupie
Groupie


Joined: 24 May 2002
Location: England
Status: Offline
Points: 121
Post Options Post Options   Thanks (0) Thanks(0)   Quote l15aRd Quote  Post ReplyReply Direct Link To This Post Topic: Naming an output file
    Posted: 11 June 2003 at 3:20am

I have written a page that can output to a word doc, but ran into a problem, I wanted to name the output file the same a the posting, here's the code i've done:

<%
Response.expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
Response.CacheControl = "no-cache"

%>
<!--#include file="db.asp"-->

<%
response.buffer = true

'get key
key = request.querystring("key")
if key="" or isnull(key) then
 key=request.form("key")
end if
if key="" or isnull(key) then response.redirect "it_postslist.asp"

'get action
a=request.form("a")
if a="" or isnull(a) then
 a="I" 'display with input box
end if

' Open Connection to the database
set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str

Select Case a
 Case "I": ' Get a record to display

  tkey = key
  strsql = "SELECT * FROM [Posts] WHERE [PostsNo]=" & tkey

  set rs = Server.CreateObject("ADODB.Recordset")
  rs.Open strsql, conn
  If rs.EOF Then
   Response.Clear
   Response.Redirect "it_postslist.asp"
  Else
   rs.MoveFirst
  End If

  ' Get the field contents
  x_PostsNo = rs("PostsNo")
  x_DatePosted = rs("DatePosted")
  x_Title = rs("Title")
  x_Post = rs("Post")

  rs.Close
  Set rs = Nothing

End Select
%>

 

<p>
<form>
<%
Response.ContentType = "application/msword"
Response.AddHeader "Content-Disposition", "attachment;filename=itpost.doc"
%>

<table border="0" cellspacing="0" cellpadding="4">

<tr>
<td ><font face="Arial" size="1"><B>Title</B>:&nbsp;<% response.write x_Title %></font>&nbsp;</td>
</tr>
<tr>
<td ><font face="Arial" size="1"><B>Post:&nbsp;</B><%= replace(x_Post & "",chr(10),"<br>") %></font>&nbsp;</td>
</tr>
</table>
</form>
<p>

can anyone help?, I've highlighted the code that creates the file in blue

Thanx in advance



Edited by l15aRd

DrunkenTechie.net

You can logoff, but you can never leave
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.