1

I want to display the complete row from the data extension on the web page.

%%[ 
VAR @Rows,@email
SET @email = QUERYPARAMETER("email") 
SET @data = QUERYPARAMETER("Trigger")
SET @Rows = LOOKUPROWS(@data,"EmailAddress",@email)
]%% 

So I want to display all the columns for the @Rows.

2 Answers 2

2

In case the column count is the same for each data extension you could use two iterations one for column and one for rows, or you can change the @colcount according to each data extension.

%%[
set colCount = 5
For @row = 1 to RowCount(@Rows) do
    For @col = 1 to @colCount do
]%%
|%%=Field(Row(@Rows,@row),@col)=%%|
%%[
    next @col
next @row
]%%
2

You'll need to iterate through the @rows result-set and use the Row() and Field() functions to retrieve the column values.

For example

%%[
var @rows, @row, @rowCount, @numRowsToReturn, @lookupValue, @i

set @lookupValue = "whee"
set @numRowsToReturn = 0 /* 0 means all */
set @rows = LookupOrderedRows("DataExtensionName",@numRowsToReturn,"DEColumn1 desc, DEColumn2 asc","LookupColumn", @lookupValue)
set @rowCount = rowcount(@rows)

if @rowCount > 0 then

for @i = 1 to @rowCount do

var @DEColumn1, @DEColumn2
set @row = row(@rows,@i) /*get row based on loop counter */
set @DEColumn1 = field(@row,"DEColumn1")
set @DEColumn2 = field(@row,"DEColumn2")

]%%

Row %%=v(@i)=%%, DEColumn1 is %%=v(@DEColumn1)=%%, DEColumn2 is %%=v(@DEColumn2)=%%

%%[

next @i ]%%

%%[ else ]%%

No rows found

%%[ endif ]%%
3
  • Thanks @Adam for the answer. I am creating a search page to search all the records in data extension. So the each data extension have different columns. I am using a Lookup based on the "Email Address" (common in all data extensions). So the name of the columns will be different each time. So is there a way I can display all columns for the row which is retrive from lookup function without specifying the column names.
    – CodeDiva
    Commented Dec 3, 2014 at 21:33
  • You can use the API functions of AMPScript or ET's Server-Side JavaScript to query the DataExtension object and retrieve the column names. It's involved, but it can be done. Commented Dec 3, 2014 at 21:56
  • Here's an example that one of my smarty pants co-workers developed: pastebin.com/7L2FDFkC Commented Dec 3, 2014 at 22:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .