Gossamer Forum
Home : Products : DBMan : Customization :

newrecords.cgi

Quote Reply
newrecords.cgi
I'm wondering how this code can be changed to output multiple Types?:

sub html_new_records {
# --------------------------------------------------------

$in{$db_key} = "*";

# Change the number below to the number of most recent records you want to display
$in{'mh'} = 2;

$in{'so'} = "descend";

# Change the number below to the *number* of your counter field or date field
$in{'sb'} = 0;

my ($status, @hits) = &query("view");

my ($numhits) = ($#hits+1) / ($#db_cols+1);
my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits);

&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: New Listings.</title>
</head>

<body bgcolor="#DDDDDD">
<blockquote>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 valign=top>
<tr><td colspan=2 bgcolor="navy"><FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: New Listings</b>
</font></td></tr>
</table>
<p>|;

if ($status ne "ok") {
print "<$font>There are no records in the database.</font>";
}
else {
print qq|<$font>These are the most recent additions to $html_title.</font>|;

# Go through each hit and convert the array to hash and send to
# html_record for printing.
for (0 .. $numhits - 1) {
print "<P>";
&html_record (&array_to_hash($_, @hits));
}
}
print qq|
<p>
<table border=0 bgcolor="#DDDDDD" cellpadding=5 cellspacing=3 width=500 valign=top>
<tr><td>|; &html_footer; print qq|</td></tr>
</table>
</blockquote>
</body>
</html>
|;
}
Quote Reply
Re: newrecords.cgi In reply to
Do ask too hard of questions? I'd practically be willing to pay for the answer Smile
Quote Reply
Re: newrecords.cgi In reply to
 
Quote:
output multiple Types

What do you mean? Yes, I have read your other Topic, but I am confused by what you mean by output multiple Types.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: newrecords.cgi In reply to
What i mean is, the new records will display the newest records by date. How can you change it to display new records by Categories. Say if i have 3 categories and I want it to create a page with 3 records, one from each category.

thanks

ryan
Quote Reply
Re: newrecords.cgi In reply to
well..can anyone help??? willing to pay.

ryan
Quote Reply
Re: newrecords.cgi In reply to
Ryan, like Eliot, I'm an unclear on what you want. Could you give me a concrete example, with sample data? I need an example of the data that would be returned from the search and an example of what you want the resulting page to look like.


------------------
JPD





Quote Reply
Re: newrecords.cgi In reply to
Hi JP,
I'd like to have a main page that displays one record of each of my categories. Each display would be of the newest added entry in each category. if i add a new record to a category then that new entry would be displayed on this main page.

a simple example would be like:
Newest Event - 3/01/00
newest article 3/01/00

then if i add a new event, the page would display:
newest event - 3/01/15
newest article 3/01/00

for a quick sample check out this page. this page just shows all my events, but the page i need help with will show 1 item from each category.

http://24.11.140.106/cgi-bin/streetracing/dss/db.cgi?db=default&uid=default&ID=&Title=&URL=&Type=Event&Date=&Image=&Description=&keyword=&mh =10&sb=4&so=descend&view_records=View+Records&nh=1

hope that helps.

Quote Reply
Re: newrecords.cgi In reply to
sorry, that last link is not coming up, try this one:
http://24.11.140.106/cgi-bin/streetracing/dss/db.cgi?db=default&uid=default&view_records=1&ID=*

thanks again.
Quote Reply
Re: newrecords.cgi In reply to
I understand now.

I'm assuming you have one field in your database that gives the "Category" --

Event
Article
Others(?)

You would need to do a search for each possible option in "Category" field. (Let's hope there are a finite number of possibilites! Smile )

It would be best if you have defined the options for the field as select fields in your .cfg file. I'm going to assume you have done this.

You'll need to move around some code in your subroutine. I guess the easiest way to show you is to just give you the whole thing.

Code:
sub html_new_records {
# --------------------------------------------------------
&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: New Listings.</title>
</head>

<body bgcolor="#DDDDDD">
<blockquote>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 valign=top>
<tr><td colspan=2 bgcolor="navy"><FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: New Listings</b>
</font></td></tr>
</table>
<p>|;

print qq|<$font>These are the most recent additions to $html_title.</font>|;

$in{'so'} = "descend";
$in{'sb'} = 0;

@fields = split (/\,/, $db_select_fields{Category});
foreach $cat (@fields) {
$in{'Category'} = $cat;
my ($status, @hits) = &query("view");
my ($numhits) = ($#hits+1) / ($#db_cols+1);
my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits);
if ($status eq 'ok') {
print "<P>";
&html_record (&array_to_hash(0, @hits));
}
}

print qq|
<p>
<table border=0 bgcolor="#DDDDDD" cellpadding=5 cellspacing=3 width=500 valign=top>
<tr><td>|; &html_footer; print qq|</td></tr>
</table>
</blockquote>
</body>
</html>
|;
}

This will give you the most recent record in each category.


------------------
JPD





Quote Reply
Re: newrecords.cgi In reply to
JPD, you rule!!!

thank you Smile

ryan
Quote Reply
Re: newrecords.cgi In reply to
the code works great!

i do have one little last questions.

If i want to define what category to show what would i add? I'm going to sort them out in a certain order. Does that make sense?

thanks again

ryan
Quote Reply
Re: newrecords.cgi In reply to
I could be wrong, but try changing:

@fields = split (/\,/, $db_select_fields{Category});

to something like this ... listing your categories:

@fields = split (/\,/,'Cars,Trucks,Sport Utility,Vans or Minivans,RV,Other');
Quote Reply
Re: newrecords.cgi In reply to
Yep. Lois is right. You can list just the categories you want, in the order you want them to appear, in the script itself.



------------------
JPD





Quote Reply
Re: newrecords.cgi In reply to
wow, works again! both you are totally cool. really i had this huge smile on my face.
Quote Reply
Re: newrecords.cgi In reply to
very last question, since i might use the side by side records, what would i put in this to make it display the last 2 records?

thanks again!

ryan
Quote Reply
Re: newrecords.cgi In reply to
That changes quite a bit.

You'll need to put

$in{'mh'} = 2;

back into the script. It can go right at the beginning of the subroutine.

Then change

Code:
if ($status eq 'ok') {
print "<P>";
&html_record (&array_to_hash(0, @hits));
}

to

Code:
if ($status eq 'ok') {
print "<P>";
for (0 .. $numhits - 1) {
print "<P>";
&html_record (&array_to_hash($_, @hits));
}
}

I think that's all, but I'm not sure. I gotta go to bed! Smile


------------------
JPD





Quote Reply
Re: newrecords.cgi In reply to
wow, i'm looking at our times, we stay up late!