![]() |
|
|
Display your recordset in a 3 column table layout using the Mod OperatorThe code below retrieves a recordset from our "tblFriends" table in the database 'Friends.mdb'. The table has 3 columns, firstly an 'ID' field that is an autonumber, secondly a field called 'FirstName' which is a textfield and lastly another textfield called 'SurName'. The code displays the results in a 3 column table layout. If you wish to change the number of columns displayed then simply change the line If iColumnSpan Mod 3 =0 Then, with 3 being the number of columns you want. The VBScript Mod operator divides two numbers and returns the remainder. So in our code if iColumnSpan is divisible by 3 leaving a remainder of 0 then start a new table row. <%@ Language="VBScript" %> 'declare SQL statement that will query the database 'define the connection string, specify database
'create an ADO connection and recordset 'Open the connection to the database 'Open the recordset object, execute the SQL statement 'first of all determine whether there are any records Response.write "<table width=""100%""
border=""1"">" iColumnSpan=iColumnSpan + 1 'move on to the next record response.write "</tr>" End If
If you have any code snippets to share with full credit given then send an email to Codesnippets - You'll receive full credit and a link back to your site. Site developed by Michael Wall - Web Design Belfast N.Ireland. |
|