SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Location
    Baltimore
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Looping Question

    I have been trying to figure this out and I'm just stumped. I have 2 pages: /lookup.asp (which has a text box that for the txt number entry) and then /check.asp (which does the lookup and displays the information).

    The first part w/ the /lookup.asp page work. It pushes the number over correctly to the /check.asp page. The problem w/ the /check.asp page is this: 1) when the results are displayed, it finds the correct record and then it displays an infinite number of blank records and 2) i would like to be able to display a message if the record isn't found.

    Thanks in advance.

    <%@ Language=VBScript %>
    <%
    ' This is an example of ASP that is pure code.
    id = request.form("id")
    %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <style type="text/css">
    <!--
    body {
    background-color: #666666;
    }
    .style29 {font-size: 11px; font-family: Arial, Helvetica, sans-serif; }
    .style31 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: bold;
    }
    .style32 {font-size: 12px; font-family: Arial, Helvetica, sans-serif;}
    -->
    </style>
    <style type="text/css">
    <!--
    .style33 {font-size: 16px}
    .style34 {font-size: 16}
    -->
    </style>
    </head>

    <body>
    <table width="700" border="0" align="center" cellpadding="0" cellspacing="0">

    <tr>
    <td><div align="center"><!--#include virtual="/nav/nav.inc"--></div></td>
    </tr>
    <tr>
    <td><table width="801" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="15" valign="top"><img src="/layout/leftdivider.jpg" alt="image" width="17" height="871" /></td>
    <td width="163" valign="top" bgcolor="#666666"><!--#include virtual="/nav/left.inc"-->&nbsp;</td>
    <td width="440" valign="top" bgcolor="#FFFFFF"><table width="439" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="433"><table width="439" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="324"><a href="/baseball/yogiberra/index.asp"><img src="/images/donmattingly/mattinglyberra.jpg" alt="Yogi Berra and Don Mattingly" width="327" height="93" border="0" /></a></td>
    <td width="105"><img src="/layout/exclusive2.gif" width="113" height="93" border="0" usemap="#Map" /></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td class="style32"><a href="/index.asp">Home</a> : COA Hologram Registration </td>
    </tr>
    <tr>
    <td><table width="437" border="0" cellpadding="0" cellspacing="1">
    <tr>
    <td width="140"><div align="center"></div></td>
    <td width="10">&nbsp;</td>
    <td width="120"><div align="center"></div></td>
    <td width="9">&nbsp;</td>
    <td width="162"><div align="center"></div></td>
    </tr>
    <tr>
    <td height="10" colspan="5"><p class="style31">&nbsp;</p>
    <div align="center"></div></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td class="style31"><table width="438" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td><table width="421" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="24">&nbsp;</td>
    <td width="397">
    <%
    'id = Request.Form("id")
    ' This connection string uses an ODBC System Data Source (DSN) on the web server.
    ' The DSN has all the database access information necessary for connecting to the Database.
    connectionstring = "DRIVER={MySQL ODBC 3.51 Driver};Server=xxx.com;Database=xxx;uid=xxx;password=xxx;"
    ' This creates and establishes a connection to the database
    Set cn = Server.CreateObject("ADODB.Connection")
    On error resume next
    cn.Open connectionstring
    if err <> 0 then
    response.Write("Error: " & err)
    else
    ' This defines a dataset object that will receive the results of any DB queries.
    Set member = Server.CreateObject("ADODB.Recordset")
    member.ActiveConnection = cn
    '
    'sqltext = "select * from description "
    sqltext = "select * from description where id = '" & id & "'"
    'This creates a SQL statement that will be used to query the dabase
    'sqltext = "select * from description where id = '"
    ' This sends the SQL command to the database. Results will be returned to the dataset.
    On error resume next
    member.open sqltext
    if err <> 0 then
    response.Write("Error: " & err)
    end if
    do while NOT member.EOF
    %>

    <p>id: <%response.write(member("id"))%><br />
    playername: <%response.Write(member("playername"))%><br />
    itemtype%response.Write(member("itemtype"))%><br />
    itemdescription%response.Write(member("itemdescription"))%><br />
    inscription%response.write(member("inscription"))%><br />
    signingdate%response.Write(member("signingdate"))%><br />
    signinglocation%response.write(member("signinglocation"))%>
    </p></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><a href="http://www.ironcladauthentics.com/coa/register.asp?id=<%response.write(id)%>">Register Your Item Now</a> </td>
    </tr>
    </table>
    <br />
    <%
    member.Close
    loop
    cn.Close
    'Response.Redirect(url)
    end if
    %>
    &nbsp;</td></tr>
    </table></td>
    </tr>
    <tr>
    <td class="style31"><p align="center">&nbsp;</p></td>
    </tr>
    <tr>
    <td><span class="style31">
    <div align="center">If you have any questions please call us at <strong>800/820-7923</strong></div>
    </span></td>
    </tr>
    <tr>
    <td><div align="center"></td>
    </tr>
    </table></td>
    <td width="166" valign="top"><!--#include virtual="/nav/right.inc"-->&nbsp;</td>
    <td width="17" valign="top"><img src="/layout/leftdivider.jpg" alt="Right Divider" width="18" height="869" /></td>
    </tr>
    </table></td>
    </tr>
    </table>
    <div align="center"><!--#include virtual="/nav/footer.inc"--></div>


    <map name="Map" id="Map"><area shape="rect" coords="13,22,98,46" href="/baseball/calripken/index.asp" alt="Ironclad Authentics Exclusive Players" />
    <area shape="rect" coords="12,46,96,68" href="/baseball/donmattingly/index.asp" />
    </map></body>
    </html>

  2. #2
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use an IF statement to see if the recordset is empty, eg.

    end if
    If member.EOF Then
    Response.Write "no records
    End If

    do while NOT member.EOF

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Location
    Baltimore
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ihitman View Post
    Use an IF statement to see if the recordset is empty, eg.

    end if
    If member.EOF Then
    Response.Write "no records
    End If

    do while NOT member.EOF
    Thanks for the help. I made the change and then also changed the loop to a member.movenext and with those two changes, that fixed the problem.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •