Re: Using DBI, better option than importing into @array



On Jul 30, 4:34 pm, Jason <jwcarl...@xxxxxxxxx> wrote:

the subjects table is

Categories: id - lastmodified - subject
Actual row: 17090 - 20070730192222 - This is a test

The posts table would be like:

Categories: id - subject - postdate - username - email - comment
Actual row: 17090 - This is a test - 20070730192222 - Jason -
jwcarl...@xxxxxxxxx - This is a test comment.

OK, try something like this (untested - I don't have a sample
database):

my $sth = $dbh->prepare(<<SQL);
select $forum_posts.id,
$forum_posts.subject,
$forum_posts.postdate,
$forum_posts.username,
$forum_posts.email,
$forum_posts.comment
from $forum_posts
left join id on ($forum_subjects.id = $forum_posts.id)
order by $forum_subjects.postdate ASC
limit 20
SQL

$sth->execute;

while (my $row = $sth->fetchrow_arrayref()) {
#do stuff
}

In retrospect, I can't quite remember why I'm duplicating the
information into the subjects table; I think it was at the suggestion
of someone in another NG.

The person who made such a suggestion is a complete idiot.

Would it be better to get rid of the "subjects" table altogether, and
just create an index with the ID field?

Absolutely.

counter for a few other things, too, though; in this case, I use it to
determine the background color of the table row (it alternates based
on whether $count is divisible by 2).

You don't need a counter to implement a simple boolean toggle;
something like this will do:

$toggle = ! $toggle;
my $color = ($toggle) ? $color1 : $color2;

But hopefully you are using a good template module (I prefer
HTML::Template) and CSS to drive your markup.



--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)

.



Relevant Pages

  • Re: What in the hell happened with racial bias.
    ... Julie are you thick?. ... I have suggested you do not read my posts. ... No. I'm not thick and I don't care what you suggest. ... Chuck you are still burning over my suggestion that you do not clutter ...
    (alt.support.diabetes)
  • How to solve downloading problem?
    ... Thanks for every suggestion for my previous posts. ... I wanted to accomplish the following task. ... The user must be notified that the download is complete. ...
    (microsoft.public.fox.helpwanted)
  • Help me with downloading problem..
    ... Thanks for every suggestion for my previous posts. ... I wanted to accomplish the following task. ... The user must be notified that the download is complete. ...
    (microsoft.public.fox.programmer.exchange)
  • Help me with downloading problem
    ... Thanks for every suggestion for my previous posts. ... I wanted to accomplish the following task. ... The user must be notified that the download is complete. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Using a Newsgroup to publish and teach
    ... our posts, and it would be easy for users to jump to. ... I'll take a look at your suggestion. ... > Hi Tom, ... >> newsgroup rather than publishing the topic in some magazine? ...
    (microsoft.public.access.queries)