Gossamer Forum
Home : Products : DBMan : Customization :

JPDeni Question

Quote Reply
JPDeni Question
I'm about to try some code you wrote in a previous message and had a question.

If it is less than 7 days old display the image; what would the code be for if it isn't, (else) print this....

$days = 7; # number of days to look for
$new = time() - ($days * 86400);
if ( &date_to_unix($rec{'Date'}) >= $new) {
print qq|<img src="http://URL/to/new.gif">|;
}

-----
Is this possible:
If someone searches a field with the word 'online', the results will be displayed sorted by my field (6) ascendedly. Hopefully over-riding and other sort on the web page that the user may have selected. Before you helped me with a slightly different problem that works, would this be acomplished the same way.

You have been very helpfull, thank you.
Shane

[This message has been edited by shane1800 (edited June 27, 1999).]
Quote Reply
Re: JPDeni Question In reply to
JPDeni et al,

For some reason, the What's New codes that are discussed in this Item and other Items in this forum do NOT function well on NT servers. For some reason, they work fine on my UNIX server, but at work with the NT, the "What's New" link shows all active records in our database. For instance, I click on the link and I get the following URL:

http://www.coco.cc.az.us/cgi-bin/jobline/index.cgi?db=default&uid=default&Date-gt=20-Jun-1999&view_records=1&ID=*&Status=Open&sb=1&so=ascend

I have the codes set up for 8 days, but I still get records that were added before that period of time. For instance, a position was added on June 7,1999 and it is still showing up as a "New" Record.

I have looked over the codes and haven't been able to find any problems. Anyone experienced difficulties with getting the "What's New" mod working with NT, please let me know and how you may have fixed the problem.

TIA

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: JPDeni Question In reply to
I don't know if it would make a difference or not, but you don't need to include &ID=* in your link.

Make sure that your Date field has the data type set to "date."

Let me know what happens when you take out the &ID=* part of the link. I may need to access your database to be able to tell you more.



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





Quote Reply
Re: JPDeni Question In reply to
Oops!

[This message has been edited by JPDeni (edited June 28, 1999).]
Quote Reply
Re: JPDeni Question In reply to
Oops again!

[This message has been edited by JPDeni (edited June 28, 1999).]
Quote Reply
Re: JPDeni Question In reply to
Code:
$days = 7; # number of days to look for
$new = time() - ($days * 86400);
if ( &date_to_unix($rec{'Date'}) >= $new) {
print qq|<img src="http://URL/to/new.gif">|;
}
else {
print qq|<img src="http://URL/to/old.gif">|;
}

Regarding your second question, yes, it is possible, if I understand you correctly. Would the search for "online" be in one field only? Could it be in a keyword search? Just trying to figure out the code you'll need.


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





Quote Reply
Re: JPDeni Question In reply to
Your code works perfectly Smile

Yes the call will come from a search on one field only (main).
Quote Reply
Re: JPDeni Question In reply to
Okay. Let's say the search term of "online" will come from the field "Fieldname."

In sub query (db.cgi script), after

local (%sortby);

add

Code:
if ($in{'Fieldname'} eq "online") {
$in{'sb'} = 6;
$in{'so'} = "ascend";
}


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





Quote Reply
Re: JPDeni Question In reply to
In the future I would like to keep track of clicks on links in my database. Basically going through a link would record the ip address in a seperate file and if it is new go to a certain record in my DBMan database and add one to the'hits' field. Look at the date field and calculate the average hits a day in another field.

This is probaly very complicated, what I was wondering is if writting to the database constantly like that will effect people searching my database;any error messages? And also if you accept clients for things like this and if not do you know if the people at Gossamer Threads do custom work.

Thanks
Shane

[This message has been edited by shane1800 (edited June 29, 1999).]
Quote Reply
Re: JPDeni Question In reply to
I tried to write a mod for the number of hits (actually I borrowed the code from someone else) and it really messed up people's databases. I removed the code from the forum so no one else would try it.

I don't understand why, but some servers allow the saving of an IP address and some don't. It is possible that yours would, and what you want may be possible to do. I would have to think about it a lot.

I do think that writing to a hits field might slow down your database. Possibly (although I can't be sure, since this just now crossed my mind) you could have a separate database which would record the just the key value of the record and the hits. It would take quite a bit of thinking to do.

I do custom work, yes, but I'm not taking any new clients right now. I am going on vacation for a week next month and I don't want to leave anything hanging.


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





Quote Reply
Re: JPDeni Question In reply to
Thanks...I will try that. However, I do not know why removing the ID argument would make a difference. I have the same codes placed on both the UNIX and NT servers. And it works just fine on the UNIX box, but on the NT, it doesn't work.

Hmm....Very strange.

But thanks for your assistance. I will test it tomorrow (after I work on some other databases) and post my findings here.

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: JPDeni Question In reply to
Carol (JPDeni),

Very odd, indeed. Here is the link I have coded in the html.pl file:

$db_script_link_url&Date-gt=$new&view_records=1&$db_key=*&Status=Open&sb=1&so=ascend

Here are the codes I have in the sub html_home for modification date:

C O D E S
---------------------------------------------
$days = 8;
$time = time() - ($days * 86400);

my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time);

my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;
$new = "$day-$months[$mon]-$year";
---------------------------------------------

I do have the AddDate and ModifiedDate set to 'date' in the default.cfg file.

Odd, indeed.....

Any suggestions???? (Again this mod is working fine in UNIX servers, but is not working well in NT.) May be I need to set the
"time" variables to localtime??



------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited June 30, 1999).]
Quote Reply
Re: JPDeni Question In reply to
The way to know whether the $new variable is working correctly is to look at the URL of the "What's New" link. You listed it before, and it included

&Date-gt=20-Jun-1999

which means the $new variable is working just fine. The problem is that the script is not finding records where the Date field has a value greater than "20-Jun-1999."

The question now is what would cause the script not to find the records that fit the criterion. There are several possibilities.

1- You don't have a field called "Date" defined in your .cfg file.

2- The data type for the "Date" field is not set to "date."

3- There is a problem with sub date_to_unix.

4- There is a problem with the "greater than" searches function.

These are all the possibilities I can think of right now. There may be others. We may have to go through each one to eliminate it as the culprit.

So, the first thing I need you to do is check your .cfg file and make absolutely positive you have a field called "Date" and that the data type for that field is "date." If the answer to both of those is yes, then we'll need to do some looking at sub date_to_unix to make sure it's working properly.



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





Quote Reply
Re: JPDeni Question In reply to
JPDeni,

Sorry for the Confusion...I found out the problem. Instead of "Date", I have used "LastModified" as the last modified date.
I changed Date to LastModified in the link and it works great.

Thanks for your assistance and patience.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us