Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 16th, 2003, 04:48 PM
Authorized User
 
Join Date: Jul 2003
Location: , , .
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default frustrating if then quandry through recordset

i've pulled data into a recordset. now i have a loop that loops through the recordset. if it finds a particular value, it should show a table with some data. if it doesn't find this value it shows another table with some images. here is my code for one section (this section is repeated 4 times).

my problem is that BOTH pieces of my code show up. they can't both be true. what am i doing wrong? thanks.

<%


rs.movefirst
do while not rs.eof
if rs("itemNumber") = "112233" and rs("paymentStatus") = "Completed" then


%>


<td colspan="1" class="description" width="60" height="25" valign="top"><p>Item sold2233</p></td>
<td class="description" width="160" height="25" valign="top"></td>


<%


elseif rs("itemNumber") <> "112233" then


%>



<td colspan="1" class="payButtons" width="60" height="25" valign="top">
      <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
        <input type="hidden" name="cmd" value="_cart">
        <input type="hidden" name="business" value="s@as.com">
        <input type="hidden" name="item_name" value="Dragon">
        <input type="hidden" name="item_number" value="112233">
        <input type="hidden" name="amount" value=".01">
        <input type="hidden" name="return" value="http://www.scrapmenagerie.com/asp/ipn.asp">
        <input type="hidden" name="cancel_return" value="http://www.scrapmenagerie.com/sorry.asp">
        <input type="hidden" name="no_note" value="1">
        <input type="hidden" name="currency_code" value="USD">
        <input type="image" src="http://www.scrapmenagerie.com/pageImages/buyButton.gif" border="0" align="left" name="submit" alt="Make payments with PayPal - it's fast, free and 2233!">
        <input type="hidden" name="add" value="1">
      </form>
    </td>
    <td class="payButtons" width="160" height="25" valign="top">
      <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
        <input type="hidden" name="cmd" value="_cart">
        <input type="hidden" name="business" value="s@as.com">
        <input type="image" src="http://www.scrapmenagerie.com/pageImages/viewCartButton.gif" border="0" align="left" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
        <input type="hidden" name="display" value="1">
      </form>
    </td>


<%


else
end if
rs.movenext
loop


%>




 
Old July 16th, 2003, 09:10 PM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Your code looks fine.
As all of your output is hard coded can you double check that you do not have two records in the recordset with different "itemNumber" or "Completed" values.
That is one way that both branches of your if else can be run.
If more than one record is expected how do you tell them apart in HTML?
The output will be the same as it is hard coded.
 
Old July 17th, 2003, 04:36 AM
Authorized User
 
Join Date: Jul 2003
Location: , , .
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for the reply. i should always have more than 1 record in the database. the itemNumber will always be different but paymentStatus will always be "Completed". i'm not sure what you mean if there are more than 2 values i won't be able to tell them apart in html. i want 1 html code to show if it finds the value (among many) and another html code to show if it doesn't find that value. i have to look for this particular itemNumber to determine which code i should display. am i going about this the wrong way?

 
Old July 17th, 2003, 04:44 AM
Authorized User
 
Join Date: Jul 2003
Location: , , .
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

btw... this is the page results when there are just 2 records in the database. the paymentStatus for both is "Completed" and the item number sare different, 112233 and 114455. http://www.scrapmenagerie.com/dragons.asp

as you can see, both parts of the code are showing. why does the other piece show (the buttons) when my code tells it to show only when itemNumber DOES NOT equal this value?

 
Old July 17th, 2003, 08:03 PM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

When I viewed that page it apeared to be ok. the first record only had the buttons, and the rest had sold and there item number.
Maybe you page has cached on your browser or something.
Or am I still missing the point?I'll send you a pic of you page as I see it.

Rod
 
Old July 18th, 2003, 06:53 AM
Authorized User
 
Join Date: Jul 2003
Location: , , .
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks. i've moved past this code and i'm now using the code under the "values" post. i'm still having some problems though...





Similar Threads
Thread Thread Starter Forum Replies Last Post
Clone DAO Recordset into ADO Recordset kamrans74 VB How-To 0 March 6th, 2007 11:57 AM
Append Query Quandry SerranoG Access 5 November 15th, 2005 06:36 PM
frustrating trouble with events and placeholder roog ASP.NET 1.0 and 1.1 Professional 0 October 13th, 2005 08:31 AM
Convert ADO recordset to DAO recordset andrew_taft Access 1 May 5th, 2004 02:31 PM
Query Quandry Ben Access 2 February 10th, 2004 06:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.