Author |
Topic |
skyhawks
Junior Member
USA
125 Posts |
Posted - 28 February 2002 : 15:41:21
|
Is there a way i can output x amount of characters in one specific field in my access database?? what i mean is that in my REVIEW. its a long paragraph. nad I only want to display the first sentence... and i will follow with a link to see more info for that record.
thanks.
sky
<% dim conn dim rs dim strsql
set conn=server.CreateObject("adodb.connection") set rs=server.CreateObject("adodb.recordset") conn.open "newyorkdb" strsql = "Select * FROM moviereview" rs.open strsql, conn %>
<p><img src="/posters/<%= rs("imgposter") %>" border=0><br> <b><%= rs("movietitle") %></b><br> <%= rs("review") %> <a href="moviereview.asp?ID=<%= rs("ID") %>">more</a></p>
<% rs.Close conn.close set rs=nothing set conn=nothing %>
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 28 February 2002 : 17:55:27
|
<%= left(rs("review"),100) %> <a href="moviereview.asp?ID=<%= rs("ID") %>">more</a></p>
www.forumSquare.com - GauravBhabu - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying. |
|
|
skyhawks
Junior Member
USA
125 Posts |
Posted - 28 February 2002 : 18:18:55
|
Thanks Gaurav... after reading what Nikkio told me, I got it to works. thanks ppl.
|
|
|
skyhawks
Junior Member
USA
125 Posts |
Posted - 01 March 2002 : 15:39:25
|
after going the method, i realized i shouldnt do that. just getting x amount of character to display would result in cutting a word short. so I've decide to display the first sentence... that would mean I would need to look for the "." (period). this is what I wrote.. but nothing comes out.
<%= Left(rs("review"), Instr(1, rs("review"), ".")) %>
I cant remember what I wrote, my result did display a number. which was the location of the period of characters.
any help would be deeply appreciated.
sky
|
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 01 March 2002 : 17:23:05
|
What does the output look like when you just print rs("review")?
Nikkol |
|
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 01 March 2002 : 17:40:12
|
Try this
<%= Left(rs("review"), Instr(100, rs("review"), ".",1)) %>
See Demo here
www.forumSquare.com - GauravBhabu - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Edited by - GauravBhabu on 01 March 2002 17:49:04 |
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 01 March 2002 : 18:03:17
|
Ah, yes that last 1 means you're doing a text comparison (0 is default binary comparison). But should that matter if we're looking for a period?
Nikkol
Edited by - Nikkol on 01 March 2002 18:06:28 |
|
|
skyhawks
Junior Member
USA
125 Posts |
Posted - 02 March 2002 : 11:06:59
|
i'm still not getting anything to be display... this is how my code looks
jlo
<html><head><title></title></head><body> <% dim conn, rs, recCount, rec
set conn=server.CreateObject("adodb.connection") set rs=server.CreateObject("adodb.recordset") conn.Open "nydb" strsql = "Select ID FROM movie" rs.Open strsql, conn, 3 recCount = rs.RecordCount
rs.close conn.Close set rs=nothing set conn=nothing
randomize rec = int(rnd * recCount)
set conn=server.CreateObject("adodb.connection") conn.open "nydb" strsql = "Select ID, imgposter, movietitle, review FROM movie" set rs=conn.execute(strsql)
rs.MoveFirst rs.Move rec %>
<p><img src="/posters/<%= rs("imgposter") %>" border=0> <b><%= rs("movietitle") %></b><br> <%= Left(rs("review"), Instr(100, rs("review"), ".", 1)) %> <a href="/moviereview.asp?ID=<%= rs("ID") %>">more</a></p>
<% rs.Close conn.close set rs=nothing set conn=nothing %>
</body></html>
|
|
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 02 March 2002 : 11:20:47
|
What you get when you use just this
<%= rs("review")%>
www.forumSquare.com - GauravBhabu - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying. |
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 02 March 2002 : 11:23:36
|
Do you get output for the picture and movie title?
Nikkol |
|
|
skyhawks
Junior Member
USA
125 Posts |
Posted - 02 March 2002 : 12:07:36
|
GauravBhabu,
when I write <%= rs("review") %> I will get all the data (TEXT) in that field.
Nikkol,
Yes, the poster and the movietitle do get displayed as well.
this is the html source code when i run that asp page.
<html><head><title></title></head> <body> <p><img src="/posters/crossroads_poster_small.jpg" border=0><br> <b>Crossroads </b><br>
<a href="/moviereview.asp?ID=1">more</a></p> </body></html>
|
|
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 02 March 2002 : 12:20:28
|
Try this
<%=Mid(rs("review"),1,instr(20,rs("review"),".",1))%>
www.forumSquare.com - GauravBhabu - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying. |
|
|
skyhawks
Junior Member
USA
125 Posts |
Posted - 02 March 2002 : 12:42:41
|
nope.. same thing.
|
|
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 02 March 2002 : 12:49:19
|
Try these
<%=Left(rs("review"),100)%>
<%=Mid(rs("review"),1,100)%>
www.forumSquare.com - GauravBhabu - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying. |
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 02 March 2002 : 13:12:13
|
Maybe this will help...
InStr([start, ]string1, string2[, compare])
Return Values The InStr function returns the following values:
If InStr returns string1 is zero-length 0 string1 is Null Null string2 is zero-length start string2 is Null Null string2 is not found 0 string2 is found within string1 Position at which match is found start > Len(string2) 0
That's from Microsoft ... i think the last one should be start>Len(string1) Nikkol
Edited by - Nikkol on 02 March 2002 13:19:07 |
|
|
Topic |
|