Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CORRECTION -Display records from a Database - extremely important

Status
Not open for further replies.

NEL3644

Technical User
Sep 4, 2000
26
US
Hi everyone,

On my Database, I have a table with 3 columns that looks like this:

ID FirstName LastName
-------------------------
1 Joe Morgan
2 Juan Martinez
3 Michael Porras
4 Brian Clark
5 Chris Clinton
6 Michelle Hwa
7 .... .....
8 .... .....
9 .... .....


Now, I want to be able to display the records in 2 tables so that it looks like this:

ID First name Last name ID First name Last name
1 Joe Morgan 4 Brian Clark
2 Juan Martin 5 Chris Clinton
3 Michael Porras 6 Michelle Hwa

Can anyone please help me? This is extremely important...

Thanks. [sig][/sig]
 
If you are not familiar with the "mod" function
check
If you need to brush up on "Queries as Arrays"
check out and search through the list and array functions.

This is just one approach more for fun than anything....


<cfquery datasource=&quot;cfhub&quot; name=&quot;getData&quot;>
Select ID,FirstName,LastName from TableName
</cfquery>

<cfset Row1 = Fix(getData.RecordCount/2)>
<cfset Row2 = Round(getData.RecordCount/2)>

<!---Check Odd/Even number of records--->
<cfif (getData.RecordCount mod 2) is 0>
<cfset Odd=0>
<cfelse>
<cfset Odd=1>
</cfif>


<cfoutput>
<table width=100% cellpadding=0 cellspacing=0>

<cfloop from=1 to=#Row1# index=index>

<tr>
<td>#getData.ID[Index]#</td>
<td>#getData.FirstName[Index]#</td>
<td>#getData.LastName[Index]#</td>
<td> </td>
<td>#getData.ID[Index+Row1]#</td>
<td>#getData.FirstName[Index+Row1]#</td>
<td>#getData.LastName[Index+Row1]#</td>
</tr>

</cfloop>

<!---Optional Odd Row--->
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td>#getData.ID[Row1+Row2]#</td>
<td>#getData.FirstName[Row1+Row2]#</td>
<td>#getData.LastName[Row1+Row2]#</td>
</tr>
</table>
</cfoutput>

If you have any other questions drop me a line at
discussion@cfhub.com
 
See also the response to &quot;Multiple rows...&quot; (about 50 queries back) for a way to do this client side using JavaScript. [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top