Gossamer Forum
Home : Products : DBMan : Customization :

Search on photo's records

Quote Reply
Search on photo's records
hi,
I have the file-upload mod installed that allow user to upload the photo. I would like to konw how to let user to search on those records which have photo there.
For example, there is a checkbox on the search page that allow user to click on it if they want to search those records with a photo there.
could any one tell me how to do it ???
Thanks in advance Smile
Quote Reply
Re: Search on photo's records In reply to
This is something that I have no idea how to do. The searches in DBMan only allow searching within the .db file. The upload mod does not change the .db file at all, so there is no way of doing a search for records that have photos attached.



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






Quote Reply
Re: Search on photo's records In reply to
Thanks JPDeni,
Is it possible to set up a checkbox field, for example "show pic".
after user upload a photo, the "showpic" field will be automaticlly changed to "yes".
So,in the search page, there is a checkbox field to let people to click on it if they
want to search the records with photo.
Something like the following:
Code:
<INPUT TYPE="CHECKBOX" NAME="showpic">Photo
Does it work?? I just dont know how to get
the "showpic" checkbox field changed to
"yes" after user upload a photo.
Any thoughts???

Any help would be greatly appreciated!!


[This message has been edited by johnsonny (edited April 17, 2000).]
Quote Reply
Re: Search on photo's records In reply to
hi johnsonny,
I would like to do it as well..
Could any people know how to do it??

Quote Reply
Re: Search on photo's records In reply to
I thought about this last night -- as a matter of fact, I had a dream about it! -- and I think I may have a solution.

First, you will have to add another field to your database. For our purposes, I'll call it "Graphic." Add it to your .cfg file and to sub html_record_form as a hidden field. You will probably need to run the updater mod from the resource center to change your .db file.

Important! You do not want this field to be editable by anyone except possibly admin.

(Oh, while you're working with this, don't use your working database files. Copy all the files to a separate test directory. Once you know it works you can upload your files to your "real" directory. I just don't want you messing up a working database in case there's a problem.)

Change

Code:
elsif ($in{'upload_success'}) { &html_upload_success; }

to

Code:
elsif ($in{'upload_success'}) { &upload_success; }

Add the following subroutine to db.cgi

[bad code deleted]

Then you can add a field to your search form

Code:
<tr><td>Include only files that have a graphic?</td>
<td><input type="checkbox" name="Graphic" value="Yes"</td></tr>

Note that the above would only go on a search form and not on a form used to add or modify records!!


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








[This message has been edited by JPDeni (edited April 25, 2000).]
Quote Reply
Re: Search on photo's records In reply to
Hi JPDeni,
It didnot work....after i uploaded a pic ,i was searching for the record with pic. no record came out ....so i tried to donwload the .db and took a look...wah....all the records is gone except only the graphic field with
"yes" shown up...like the following in .db
Code:
okok&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;|Yes&#0124; &#0124;&#0124; &#0124;
Any ideas??

Quote Reply
Re: Search on photo's records In reply to
Oh dear! (See why I said to use this on a .db file that didn't have real info in it? Smile )

I realize now why this is happening.

Let me think about it for a bit. I was out with a headache yesterday and I have a lot to catch up on. I'll get back to you.


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






Quote Reply
Re: Search on photo's records In reply to
Are you saying that all of the records were gone, or just the one with the upload connected? If all the records were gone, I'm not sure what the problem is. If it was just the one record, the following should fix it.

Code:
sub upload_success {
# --------------------------------------------------------
my (@lines,$line,$output,@data,%rec);
open (DB, "<$db_file_name") or
&cgierr("error in upload_success. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
@lines = <DB>; # Slurp the database into @lines..
close DB;
LINE: foreach $line (@lines) {
if ($line =~ /^$/) { next LINE; } # Skip and Remove blank lines
if ($line =~ /^#/) { $output .= $line; next LINE; } # Comment Line
chomp ($line);
@data = &split_decode($line);
if ($data[$db_key_pos] eq $in{$db_key}) {
%rec = &array_to_hash(0,@data);
$rec{'Graphic'} = "Yes";
$output .= &join_encode(%rec);
}
else {
$output .= $line . "\n"; # else print regular line.
}
}
open (DB, ">$db_file_name") or
&cgierr("error in upload_success. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) {
flock(DB, 2) or &cgierr("unable to get exclusive lock on $db_file_name.\nReason: $!");
}
print DB $output;
close DB; # automatically removes file lock
&auth_logging("uploaded graphic: $in{$db_key}") if ($auth_logging);
&html_upload_success;
}

(I'm deleting the previous code so no one gets confused. Smile )


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