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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting database text

Status
Not open for further replies.

pwinstanley

IS-IT--Management
Nov 23, 2000
22
GB
What's the best way to format database text?

Put basic html tags (such as <br>) in the datasbase and add more to the page when required?

Some other way that keeps tags out of the database.

Thanks
Paul
 
I like to use a table to show parts.
Each part is in its own row and the columns lend nicely to fields.
Plus it grows as the Recordset results very
here is a sample of what it one looks like.


here is some VBScript .ASP code to make it.
--------------------------------
<html><head>
<TITLE>Parts respond.asp</TITLE>
</head>

<body bgcolor=&quot;#FFFFFF&quot;>
<%pnum=request.querystring(&quot;PartNumber&quot;)%>
<%desc=request.querystring(&quot;Description&quot;)%>
<%Customer=request.querystring(&quot;Customer&quot;)%>
<%
Set Conn = server.CreateObject(&quot;ADODB.Connection&quot;)
Conn.Open &quot;driver=SQL Server;server=yourserver.com;uid=user;pwd=pass;database=yourdb;&quot;
Set RS = Conn.Execute(&quot;SELECT Count(*) AS Recs FROM [Copy-PartMaster Lite] Where [STOCK_CODE] Like N'&quot; & pnum & &quot;%' And [Description] Like N'&quot; & desc & &quot;%'&quot;)
Set RS1 = Conn.Execute(&quot;SELECT [STOCK_CODE], [Description], [SELLING_PRICE] FROM [Copy-PartMaster Lite] Where [STOCK_CODE] Like N'&quot; & pnum & &quot;%' And [Description] Like N'&quot; & desc & &quot;%'&quot;)
%>
<form action=&quot;shopcart.asp&quot; method=get>
<input type=&quot;hidden&quot; name=&quot;Customer&quot; value=&quot;<%=Customer%>
<p align=&quot;left&quot;>
<font color=&quot;#000000&quot;>&nbsp;&nbsp;&nbsp; Enter a PO Number </font><input type=&quot;text&quot; name=&quot;PONumber&quot; size=&quot;20&quot;>

if you want to order this part.

<table border=&quot;1&quot; width=&quot;90%&quot;>
<tr>
<th width=&quot;100%&quot; align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; valign=&quot;middle&quot;>
<p align=&quot;left&quot;><%Response.Write &quot;Records returned &quot; & RS(&quot;Recs&quot;)%></th>
</tr>
</table>
<table border=&quot;1&quot; width=&quot;90%&quot; bordercolor=&quot;#0066FF&quot;>
<tr>
<td width=&quot;10%&quot; align=&quot;left&quot; bordercolor=&quot;#000000&quot; bgcolor=&quot;#000000&quot;>
<p align=&quot;left&quot;><font color=&quot;#FFFFFF&quot;>Add to PO</font></td>
<td width=&quot;18%&quot; align=&quot;left&quot; bordercolor=&quot;#0066FF&quot; bgcolor=&quot;#000000&quot;>
<p align=&quot;left&quot;><font color=&quot;#FFFFFF&quot;>Part Number</font></td>
<td width=&quot;52%&quot; align=&quot;left&quot; bordercolor=&quot;#000000&quot; bgcolor=&quot;#000000&quot;>
<p align=&quot;left&quot;><font color=&quot;#FFFFFF&quot;>Description</font></td>
<td width=&quot;12%&quot; align=&quot;right&quot; bordercolor=&quot;#000000&quot; bgcolor=&quot;#000000&quot;>
<p align=&quot;left&quot;><font color=&quot;#FFFFFF&quot;>Price</font></td>
<td width=&quot;8%&quot; align=&quot;right&quot; bordercolor=&quot;#000000&quot; bgcolor=&quot;#000000&quot;>
<p align=&quot;left&quot;><font color=&quot;#FFFFFF&quot;>Qty</font></td>
<tr>
<td width=&quot;10%&quot; align=&quot;left&quot;>&nbsp;</td>
<td width=&quot;18%&quot; align=&quot;left&quot;>&nbsp;</td>
<td width=&quot;52%&quot; align=&quot;left&quot;>&nbsp;</td>
<td width=&quot;12%&quot; align=&quot;right&quot;>&nbsp;</td>
<td width=&quot;8%&quot; align=&quot;right&quot;>&nbsp;</td>
</tr>

<%
If Not RS1.EOF Then
Do%>
<tr>
<td width=&quot;10%&quot; align=&quot;left&quot;>
<p align=&quot;center&quot;><input type=&quot;submit&quot; value='Add <%=RS1(&quot;STOCK_CODE&quot;)%>' name=&quot;addtopo&quot;></td>
<td width=&quot;18%&quot; align=&quot;left&quot;>
<p align=&quot;center&quot;><%Response.Write RS1(&quot;STOCK_CODE&quot;)%></td>
<td width=&quot;52%&quot; align=&quot;left&quot;>
<p align=&quot;center&quot;><%Response.Write RS1(&quot;Description&quot;) %></td>
<td width=&quot;12%&quot; align=&quot;right&quot;>
<p align=&quot;center&quot;><%Response.Write RS1(&quot;SELLING_PRICE&quot;) %></td>
<td width=&quot;8%&quot; align=&quot;right&quot;><input type=&quot;text&quot; name=&quot;Qty&quot; size=&quot;4&quot;>
<p align=&quot;center&quot;></td>
</tr>
<% RS1.Movenext
Loop Until RS1.EOF
Else

Response.Write(&quot;No records or something&quot;)
End If
%>

</table>
</form>
<p><font size=&quot;1&quot;>Written by: Douglas Poston <a href=&quot;mailto:dposton@universal1.com&quot;>dposton@universal1.com</a></font>

</p>

</body> DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
You can always format what's coming out of the database if you'd like.

Just call Server.HTMLEncode, and all the html tags inside the DB get translated to text.

eg:
<br>
becomes
& lt;br & gt;

with no spaces, of course

hope this helps
leo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top