Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Add condition in my global

Quote Reply
Add condition in my global
Hi,
i need to put a condition in my global, like:
Select only the datarecords, which are "MagArt = "gumag".

How can i insert this condition?

Code:
sub {
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
my $ausgabe = $IN->param('Ausgabe');
$search_db->select_options ('ORDER BY Add_Date ASC Limit 20');
$sth = $search_db->select ( { Ausgabe => $ausgabe });
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 200) {
$link->{Title} = substr($link->{Title}, 0, 20) . '...';
}
$output .= Links::SiteHTML::display ('login_gutscheine_include', $link);
}
return $output;
}


Thanks in advance!

Coyu
Quote Reply
Re: [Coyu] Add condition in my global In reply to
Here it is:
Code:
sub {
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
my $ausgabe = $IN->param('Ausgabe');
$search_db->select_options ('ORDER BY Add_Date ASC Limit 20');
$sth = $search_db->select ( { Ausgabe => $ausgabe, MagArt => 'gumag' });
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 200) {
$link->{Title} = substr($link->{Title}, 0, 20) . '...';
}
$output .= Links::SiteHTML::display ('login_gutscheine_include', $link);
}
return $output;
}

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Add condition in my global In reply to
Hi webmaster33,

Thank you very much! It works! ,-)

I have a further question:
Could i say in the code:
When you get an empty list (no datarecords), then get the last 20 entries (ignoring the "Ausgabe"-condition") in table?

Thank you very much in advance!

coyu
Quote Reply
Re: [Coyu] Add condition in my global In reply to
Hi,

Try this :) (untested, but should work)

Code:
sub {
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
my $ausgabe = $IN->param('Ausgabe');

$search_db->select_options ('ORDER BY Add_Date ASC Limit 20');
$sth = $search_db->select ( { Ausgabe => $ausgabe, MagArt => 'gumag' });
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 200) {
$link->{Title} = substr($link->{Title}, 0, 20) . '...';
}
$output .= Links::SiteHTML::display ('login_gutscheine_include', $link);
}

if ($sth->rows < 1) {

$search_db->select_options ('ORDER BY Add_Date ASC Limit 20');
$sth = $search_db->select ( { Ausgabe => $ausgabe });
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 200) {
$link->{Title} = substr($link->{Title}, 0, 20) . '...';
}
$output .= Links::SiteHTML::display ('login_gutscheine_include', $link);
}

}

return $output;
}

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!