Useful database code

Code for 'Select' statements    
fp_sQry="SELECT * FROM table WHERE (Done = ""1"" AND Pword = '::pword::' AND DOD LIKE '::dait::%' AND sirname LIKE '::nayme::%')"
fp_sQry="SELECT * FROM table WHERE (Arm IS NOT NULL AND sirname LIKE '::Lastname::%') ORDER BY vets.sirname ASC,vets.fames ASC"
     
Code to query the results    
<% If fp_rs("Dy") = "1" OR fp_rs("Dy") = "21" OR fp_rs("Dy") = "31" then %>    
<% If fp_rs("Lynk") <> "" then %>    
     
Code to format the results    
<%= Right(FP_FieldVal(fp_rs,"DOD"),4)%>    
<%=FormatDateTime(FP_FieldVal(fp_rs,"entdate"),1)%>    
     

<!--#include virtual="_fpclass/fpdbrgn1.inc"-->
     <% If gw = 0 then %>
          <tr>
     <% end if %>
     <% gw = gw + 1 %>
     <% If gw <= 7 then %>
                    <td>
                         <div align="center">
                              <table border="0" style="border-collapse: collapse">
                                   <tr>
                                        <td align="center">
                                             CODE FOR THE FIELD BEING DISPLAYED
                                        </td>
                                   </tr>
                              </table>
                         </div>
                    </td>
                    <td>&nbsp;</td> <!-- Not required in the 'Else' statement -->
     <% Else %>
                    <td>
                         <div align="center">
                              <table border="0" style="border-collapse: collapse">
                                   <tr>
                                        <td align="center">
                                             CODE FOR THE FIELD BEING DISPLAYED
                                        </td>
                                   </tr>
                              </table>
                         </div>
                    </td>
          </tr>
          <tr>
               <td colspan="13" height="4"><hr color="#008080" width="85%"></td><!-- puts a line between rows -->
          </tr>
          <% gw = 0 %>
     <% end if %>
<!--#include virtual="_fpclass/fpdbrgn2.inc"-->
 

Code to display Database results across a page.

gw can be any variable name

7 change value as required


     
MS Access    
 IIf([Dy]="1" OR [Dy]="21"OR [Dy]="31" ,"st", IIf([Dy]="2" OR [Dy]="22" ,"nd",IIf([Dy]="3" OR [Dy]="23" ,"rd","th"))) AS ndate