Gossamer Forum
Home : Products : DBMan : Installation :

Different message in delete_success

Quote Reply
Different message in delete_success
Can I display a different column from the deleted record than the key?
Example: Each record contains 'ID' + 'Name'
'ID' is the key.
I want to display the following message:
"The following record was deleted: 'xxx'!"
How?

P.S.: Thanks JPDeni for the help in the previous problem!
Quote Reply
Re: Different message in delete_success In reply to
You're very welcome! Smile

It would take a quite a bit of changing in the db.cgi script to get the info you want, since the whole delete routine works on the $db_key and by the time you get the message on the delete success thing, the record is gone and you can't access it.

Not that it can't be done! Smile

Look in db.cgi, sub delete_records for the following (I've taken out the comments on the lines):

Code:
$delete_list{$data[$db_key_pos]} ? ($delete_list{$data[$db_key_pos]} = 0) :
($output .= $line . "\n");

Change the above section to

Code:
if ($delete_list{$data[$db_key_pos]}) {
$delete_list{$data[$db_key_pos]} = 0;
$delete_name{$data[$db_key_pos]} = $data[#];
}
else {
$output .= $line . "\n";
}

Replace # above with the field number of your name field.

A little further down, you'll see

Code:
foreach $key (keys %delete_list) {
$delete_list{$key} ?
($errstr .= "$key,") :
($succstr .= "$key,");
}

Change this to

Code:
foreach $key (keys %delete_list) {
$delete_list{$key} ?
($errstr .= "$key,") :
($succstr .= "$delete_name{$key},");
}

I haven't tried this, but it should give you the list of names that have been successfully deleted. If any aren't deleted, though, you'll just get the ID number. Then again, the only reason they weren't deleted is because the ID wasn't found, so the name wouldn't be available anyway. Smile


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