Hjælp til at udskrive fra anden tabel
Hej !Har følgende DB:
Test.mdb
indeholder 2 tabeller:
Billeder
--------
ID
Sti
Testtabel
---------
ID_no
og diverse andre felter
ID_no er primær nøgle i testtabel og har en relation til ID i billeder. Der er ingen nøgler i billeder-tabellen.
Jeg har så en side der via af en select side udskriver data fra testtabellen. Nu vil jeg så have samme side skal udskrive alle data fra billeder-tabellen der har samme id nummer som id_no fra testtabellen. Jeg har prøvet alt muligt og nu smider jeg lige hele koden. Se om i kan hjælpe mig og spørg endelig.
Det er næsten nederst jeg så prøver at skrive det ud der står i sti i billeder tabellen
*****************
<% Session.LCID=1030 %>
<%
'if isEmpty(session("UserID")) then
' Response.Redirect "../../bruger/asp/logadmin.asp?msg=" & Server.URLEncode ("Du skal være logget ind for at se fangstrapporter.")
'end if
%>
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsGuestbook 'Holds the recordset for the record to be updated
Dim strSQL 'Holds the SQL query for the database
Dim strsql2
Dim lngRecordNo 'Holds the record number to be updated
'Read in the record number to be updated
lngRecordNo = CLng(Request.QueryString("ID"))
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../db/test.mdb")
'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"
'Create an ADO recordset object
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT testtabel.* FROM testtabel WHERE ID_no=" & lngRecordNo
strsql2 = "SELECT billeder.* FROM billeder WHERE ID=" & lngRecordNo
'Open the recordset with the SQL query
rsGuestbook.Open strSQL, adoCon
%>
<html>
<head>
<title>View_selected</title>
<link rel="stylesheet" type="text/css" href="../../style.css">
<meta http-equiv="Cache-Control" content="no-store">
<meta http-equiv="Pragma" content="no-cache">
</head>
<body bgcolor="#232323" text="black">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="530" id="AutoNumber2">
<tr>
<td width="100%" class=head align=center>
<% = rsGuestbook("forfatter") %>'s fangstrapport
</td>
</tr>
<tr>
<td width="100%">
</td>
</tr>
</table>
</center>
</div>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="530" id="AutoNumber2">
<tr>
<td width="100%" align=left class=text1>
<a href="view_select_bg.asp">
Tilbage
</a>
</td>
</tr>
</table>
</center>
</div>
<br>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" style="border-width:0px; border-collapse: collapse" width="530" id="table2" bordercolor="#000000">
<tr>
<td colspan="4" align=center class="head" ><b><% = rsGuestbook("overskrift") %></b></td>
</tr>
<tr>
<td colspan="4" align=center class="head"> </td>
</tr>
<tr>
<td class="text1" rowspan="9" width="20%" style="border-left: medium none #000000; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom: medium none #000000">
<%if len(rsGuestbook("url"))>0 then
maksbredde = 150
makshojde = 180
'
'
'Du mangler at ha' komponenten (ImgSize.Check) installeret på serveren Kristian!
'Den bruges til at finde ud af, hvor stort billedet er!
'Måske hedder den noget andet hos din udbyder!?
'
Set objImg = Server.CreateObject("ImgSize.Check")
objImg.FileName = server.mappath(rsGuestbook("url"))
if objImg.Height > makshojde then
ratio = objImg.Height / makshojde
newheight = objImg.Height /ratio
newwidth = objImg.Width /ratio
if newwidth > maksbredde then
ratio = newwidth / maksbredde
newheight = newheight /ratio
newwidth = newwidth /ratio
end if
elseif objImg.Width > maksbredde then
ratio = objImg.Width / maksbredde
newheight = objImg.Height /ratio
newwidth = objImg.Width /ratio
if newheight > makshojde then
ratio = newheight / makshojde
newheight = newheight /ratio
newwidth = newwidth /ratio
end if
else
newheight = objImg.Height
newwidth = objImg.Width
end if
%>
<a href="<%= rsguestbook("url")%>" target=_blank>
<img src="<%= rsguestbook("url")%>" border="0" height="<%= newheight %>" width="<%= newwidth %>" align="top"></a>
<% else %>
<img src="../images/nopix.gif" border="0" align="top">
<%end if%>
</td>
<td class="text1" width="4%" style="border-style: none; border-width: medium">
</td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">
Indsendt af</td>
<td class="text1" style="border-style: none; border-width: medium" >
:<% = rsGuestbook("forfatter") %></td>
</tr>
<tr>
<td class="text1" width="4%" style="border-style: none; border-width: medium"> </td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">Dato for fangst</td>
<td class="text1" style="border-style: none; border-width: medium" >
:<% = rsGuestbook("fangstmnd") %></td>
</tr>
<tr>
<td class="text1" width="4%" style="border-style: none; border-width: medium"> </td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">Fangst</td>
<td class="text1" style="border-style: none; border-width: medium" >
:<% = rsGuestbook("fangst") %></td>
</tr>
<tr>
<td class="text1" width="4%" style="border-style: none; border-width: medium"> </td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">Agn</td>
<td class="text1" style="border-style: none; border-width: medium" >
:<% = rsGuestbook("agn") %></td>
</tr>
<tr>
<td class="text1" width="4%" style="border-style: none; border-width: medium">
</td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">
Vægt i kg</td>
<td class="text1" style="border-style: none; border-width: medium" >
: <% = rsGuestbook("vaegt") %></td>
</tr>
<tr>
<td class="text1" width="4%" style="border-style: none; border-width: medium">
</td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">
Kategori</td>
<td class="text1" style="border-style: none; border-width: medium" >
: <% = rsGuestbook("metode") %></td>
</tr>
<tr>
<td class="text1" width="4%" style="border-style: none; border-width: medium">
</td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">
Sted</td>
<td class="text1" style="border-style: none; border-width: medium" >
: <% = rsGuestbook("sted") %></td>
</tr>
<tr>
<td class="text1" width="4%" style="border-style: none; border-width: medium">
</td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">
Oprettet d.</td>
<td class="text1" style="border-style: none; border-width: medium" >
: <% = rsGuestbook("dato") %></td>
</tr>
<tr>
<td class="text1" width="4%" style="border-style: none; border-width: medium">
</td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">
Klokken</td>
<td class="text1" style="border-style: none; border-width: medium" >
: <% = rsGuestbook("tid") %></td>
</tr>
</table>
</div>
<br>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-bottom-width:0px" width="530" id="table2" bordercolor="#000000">
<tr>
</tr>
<tr>
<%
' str = rsguestbook("beretning")
' str = replace(str, "f1", "<img src='../html-images/bid.jpg' width='45' height='62'>")
' str = replace(str, "F1", "<img src='../html-images/bid.jpg' width='45' height='62'>")
' str = replace(str, "f2", "<img src='../html-images/fisk.jpg' width='68' height='65'>")
' str = replace(str, "F2", "<img src='../html-images/fisk.jpg' width='68' height='65'>")
' str = replace(str, "so1", "<img src='../html-images/lake.jpg' width='81' height='47'>")
' str = replace(str, "SO1", "<img src='../html-images/lake.jpg' width='81' height='47'>")
' str = replace(str, "linux", "<img src='../html-images/linux.jpg' width='68' height='69'>")
' str = replace(str, "LINUX", "<img src='../html-images/linux.jpg' width='68' height='69'>")
' str = replace(str, "stang1", "<img src='../html-images/rod.jpg' width='53' height='78'>")
' str = replace(str, "STANG1", "<img src='../html-images/rod.jpg' width='53' height='78'>")
' str = replace(str, ";)", "<img src='../html-images/yellowsmile.gif'>")
' str = replace(str, ":o", "<img src='../html-images/1.gif'>")
' str = replace(str, ";-)", "<img src='../html-images/2.gif'>")
' str = replace(str, ":D", "<img src='../html-images/3.gif'>")
' str = replace(str, ":-)", "<img src='../html-images/4.gif'>")
' str = replace(str, ":(", "<img src='../html-images/5.gif'>")
%>
<td class="text1" colspan="3" style="border-left-color: #000000; border-left-width: 1px; border-right-color: #000000; border-right-width: 1px; border-top-style: none; border-top-width: medium"><%=rsguestbook("beretning")%>
<br><br>
</td>
</tr>
</table>
</div>
<br>
<center>
<img src="images/530px.gif" align="textTop" width="530" height="1"></td>
</center>
</font>
<%
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL2, adoCon
response.write rs("sti")
%>
</body>
</html>
</font><%
'Reset server objects
rsGuestbook.Close
Set rsGuestbook = Nothing
Set adoCon = Nothing
%>
