CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Displaying Results By Columns?

 



allanonline
Novice

Mar 9, 2002, 6:03 AM

Post #1 of 6 (1211 views)
Displaying Results By Columns? Can't Post

I want to be able to display the results of a search by columns.

The search currently returns a thumbnail and title, with each record going in

a new row.

tractor

mower

mower



I would like to have 3 or 4 results per row.

tractor mower mower

Any help would be appreciated.

Thank You

Allan
Unsure


mhx
Enthusiast / Moderator

Mar 9, 2002, 6:38 AM

Post #2 of 6 (1210 views)
Re: [allanonline] Displaying Results By Columns? [In reply to] Can't Post

Um, well, so what exactly do you want to know? Wink

Perhaps you like these posts:

[url=http://perlguru.com/gforum.cgi?post=12519#12519]Re: Tables, Display 2 cols only...
[url=http://forums.perlguru.com/gforum.cgi?post=12136#12136]Re: Map?

If they don't help you, please explain in a little more detail what you try to accomplish and what it has to do with Perl in particular.

-- mhx

At last with an effort he spoke, and wondered to hear his own words, as if some other will was using his small voice. "I will take the Ring," he said, "though I do not know the way."

-- Frodo



allanonline
Novice

Mar 9, 2002, 12:04 PM

Post #3 of 6 (1199 views)
Re: [mhx] Displaying Results By Columns? [In reply to] Can't Post

I am not trying to put the data from an individual record in different columns.

I have a database of of vehicles and a cgi script that performs a search based on year, price, etc. When the results come back, I am only able to show one record per row.

looks something like;

<TABLE>

<TR>

<TD>

$record[$i]

</TD>

</TR>

</TABLE>

What I would like to do is bring back 4 records within each column

<tr>

<td>$record[1]</td>

<td>$record[2]</td>

<td>$record[3]</td>

<td>$record[4]</td>

</tr>

<tr>

<td>$record[5]</td>

<td>$record[6]</td>

<td>$record[7]</td>

<td>$record[8]</td>

</tr> ........ and so on



Hope this explains it a litlle better

Thanks Again

Allan
Unsure


mhx
Enthusiast / Moderator

Mar 9, 2002, 2:24 PM

Post #4 of 6 (1194 views)
Re: [allanonline] Displaying Results By Columns? [In reply to] Can't Post

So you want to modify the CGI script? Could you post the relevant part? (The part that generates the HTML code.)

-- mhx

At last with an effort he spoke, and wondered to hear his own words, as if some other will was using his small voice. "I will take the Ring," he said, "though I do not know the way."

-- Frodo



yapp
User

Mar 10, 2002, 6:48 AM

Post #5 of 6 (1187 views)
Re: [allanonline] Displaying Results By Columns? [In reply to] Can't Post

So basically, you have a list of items you want to display in a table?
After 5 items a new row should be printed?
You can use the modulus function for that. (returns the remainder of a division)

The (beta) code will be:
[perl]
my $I = 0;
my $rows = 5;

print qq[<TABLE width="100%">\n];
print qq[ <TR>\n];

foreach my $item (@array)
{
print qq[ <TD>$item</TD>\n];
if((($I + 1) % $rows) == 0)
{
print qq[ </TR><TR>\n];
}
$I++;
}

print qq[ </TR>\n];
print qq[</TABLE>\n];

[/perl]

Not added, but very required. After creating all the rows, you also have to create the last table cells (<TD>&nbsp;</TD>). Also check out the code for certain boundaries. That might be where things could go wrong.

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool


Paul
Enthusiast

Mar 10, 2002, 11:43 AM

Post #6 of 6 (1179 views)
Re: [allanonline] Displaying Results By Columns? [In reply to] Can't Post

Hmm coincidence. I wrote this for someone at GT the other day...

http://gossamer-threads.com/perl/gforum/gforum.cgi?post=185549;

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives