Gossamer Forum
Home : Products : DBMan : Installation :

How to reference a search through a call

Quote Reply
How to reference a search through a call
Hello all
I am wondering how I can reference a search directly from a call to html_delete_form? In the database I am developing, many records will exist for one registered person (they will all have their own ID #) What I would like is when the user goes to the home page, what shows up is every record that that person owns. I can get it to show up with a search, but I don't know how to force the program to search on one field only and display that stuff only.
Any help is appreciated.
Thanks,
Mike Potter
iam@inthehack.com

------------------
Quote Reply
Re: How to reference a search through a call In reply to
I'm not sure I understand. You mention html_delete_form and html_home.

If you want a person's records to appear in html_home, you can add some code that will do a search every time the home page is loaded.

Add the following to sub html_home:

Code:
undef %in;
$in{'Userid'} = $db_userid; # adjust to match your own user id field
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") {
for (0 .. $numhits - 1) {
print "<P>";
&html_record (&array_to_hash($_, @hits));
}
}

Be sure to end off any previous print qq| statements with a |; before you add the code.



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





Quote Reply
Re: How to reference a search through a call In reply to
Thanks, but that didn't work just right. I understand what you are trying to do, it's just that no record shows up when I do that. I have changed the line to
$in{'To'} = $db_userid; so that it matches my field (To is then assigned to the proper variable, I see that in debug mode) but still no record shows up. The reason I had put the reference to delete there is because not only do I want the recors to display, I want them to display with a little checkbox so they can be deleted right off that front page too.
Quote Reply
Re: How to reference a search through a call In reply to
I spoke too soon, that did work, but now how do I make it a delete form? Just replace html_record with html_delete_form?
Mike
Quote Reply
Re: How to reference a search through a call In reply to
So you want have the home page as the delete_form?

You'll probably want to have something there besides just the text on the delete form. Some sort of "welcome to the database" message and an explanation that users can delete from that page.

Probably the easiest way to do it would be to delete the code in html_home and instead have

undef %in;
$in{'To'} = $db_userid;
&html_delete_form;

Then you'll need to do some work on sub html_delete_form. You'll probably want to change the page title and some of the text on the page. Also, you'll want to be sure to change the text that's printed if there's no records returned. (You don't want someone to be told there's an error when they are first signing on.)

Finally, you'll probably want to make a change in sub html_footer. Since your "delete" form will be on the home page (and, presumably you don't want folks to delete any records but their own), you'll want to change

print qq!| <A HREF="$db_script_link_url&delete_search=1">Delete</A> ! if ($per_del);

to

print qq!| <A HREF="$db_script_link_url&delete_search=1">Delete</A> ! if ($per_admin);

That way, you (as admin) will still be able to delete records.


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