Avatar billede mvk Nybegynder
18. august 2003 - 11:37 Der er 4 kommentarer og
1 løsning

Random record

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/capitol.asp" -->
<%
Dim random_product__MMColParam
Dim random_product__MMColParam = "Y"
If (Request("MM_EmptyValue") <> "") Then random_product__MMColParam = Request("MM_EmptyValue")
End If
%>
<%
Set random_product = Server.CreateObject("ADODB.Recordset")
random_product.Open "SELECT * FROM product WHERE Active = '" + Replace (random_product__MMColParam, "'", "''") + "'", MM_capitol_STRING, 1, 3
If random_product.BOF or random_product.EOF Then Response.write "Ingen poster"
else
randomize
random_product.Move(int(random_product.RecordCount + rnd()))
'Response.Write random_product("IDproduct")
end if
%>
Avatar billede mvk Nybegynder
18. august 2003 - 11:38 #1
hvad er der galt med koden. jeg prøver at trække en random record ud af DBen.
Avatar billede eagleeye Praktikant
18. august 2003 - 13:16 #2
Prøv i førte omgang at rette det til dette hvor Response.write efter The er flyttet ned:
Samt lavet om i koden for at finde random recorden.

<%
Set random_product = Server.CreateObject("ADODB.Recordset")
random_product.Open "SELECT * FROM product WHERE Active = '" + Replace (random_product__MMColParam, "'", "''") + "'", MM_capitol_STRING, 1, 3
If random_product.BOF or random_product.EOF Then
  Response.write "Ingen poster"
else
randomize
randomNr = Int(random_product.RecordCount * rnd())
random_product.Move(randomNr)
Response.Write random_product("IDproduct")
end if
%>
Avatar billede mvk Nybegynder
18. august 2003 - 13:27 #3
det virker ikke, her er hele koden:

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/capitol.asp" -->
<%
Dim random_product__MMColParam
Dim random_product__MMColParam = "Y"
If (Request("MM_EmptyValue") <> "") Then random_product__MMColParam = Request("MM_EmptyValue")
End If
%>
<%
Set random_product = Server.CreateObject("ADODB.Recordset")
random_product.Open "SELECT * FROM product WHERE Active = '" + Replace (random_product__MMColParam, "'", "''") + "'", MM_capitol_STRING, 1, 3
If random_product.BOF or random_product.EOF Then
  Response.write "Ingen poster"
else
randomize
randomNr = Int(random_product.RecordCount * rnd())
random_product.Move(randomNr)
Response.Write random_product("IDproduct")
end if
%>
<html>
<head>
<title>Capitolshop</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="/capitol.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="90%" border="0" cellpadding="5">
  <tr>
    <td class="menuHead"> Featured Product</td>
  </tr>
  <tr>
    <td> <table width="100%" border="0">
        <tr>
          <td colspan="2" class="productBrand"><div align="center"><a href="/product.asp?IDproduct=<%=(random_product.Fields.Item("IDproduct").Value)%>" target="_parent"><img src="/images/product/<%=(random_product.Fields.Item("ImageName").Value)%>" width="156" border="0"></a></div></td>
        </tr>
        <tr>
          <td colspan="2" class="productBrand" height="10"></td>
        </tr>
        <tr>
          <td class="productBrand"><%=(random_product.Fields.Item("Brand").Value)%>
          </td>
          <td class="productName"><div align="center"></div></td>
        </tr>
        <tr>
          <td height="16" colspan="2" class="productName"> <%=(random_product.Fields.Item("ProductName").Value)%>
          </td>
        </tr>
        <tr>
          <td class="productName"><%=(random_product.Fields.Item("Colour").Value)%></td>
          <td class="productName"><%=(random_product.Fields.Item("Sex").Value)%></td>
        </tr>
        <tr>
          <td colspan="2" class="productPrice"><%=(random_product.Fields.Item("Price").Value)%>,00
            DKK</td>
        </tr>
        <tr>
          <td colspan="2" class="productPrice" height="10"></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td class="productPrice"><a href="/product.asp?IDproduct=<%=(random_product.Fields.Item("IDproduct").Value)%>" target="_parent" class="productPrice"><strong><font color="#DB2222">Check
      out product</font></strong></a></td>
  </tr>
  <tr>
    <td class="productPrice">&nbsp;</td>
  </tr>
</table>
</body>
</html>
<%
random_product.Close()
Set random_product = Nothing
%>
Avatar billede mvk Nybegynder
18. august 2003 - 13:27 #4
Avatar billede mvk Nybegynder
18. august 2003 - 13:33 #5
det virker - tak Eagle :)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester