Gossamer Forum
Home : Products : DBMan : Customization :

Random Record Mod

Quote Reply
Random Record Mod
Hi!

I donwnloaded the random record mod from the RC, the one that you can use on 'non' database pages. Trouble is, I am using the verification system, and as it just reads from the .db file it brings up all those unverified records!

Any way to restrict to 'approved' records only?

Here is the mod:

Code:
$db_dir_url = "http://www.xxx.com/xxx/db";
$db_script_url = $db_dir_url . "/db.pl";
$db_file = "/home/xxx/xxx/db/gallery.db";
print "Content-type: text/html\n\n";

open (DATABASE, "<$db_file") || die print "Couldn't open database!";
@line=<DATABASE>;
close (DATABASE);
srand;
$array = $line[int rand(@line)];

# If you're $db_delim is not '|', change it here (between /\ and /,)

@dbman_field = split (/\|/, $array);

# Display Section:
print qq|<center><table border="1" width="230" height="150" bordercolor="#008000" cellspacing="0" align="center">
<tr height="100"><td align="center">
<a href="db.pl?db=gallery&uid=default&view_records=1&ID=$dbman_field[0]"><IMG SRC="http://www.xxx.com/db/upload/sml_pic/$dbman_field[0].jpg" width="230" ALT="$dbman_field[1]" height="100" border="0"></a></td>
</tr><tr><td align="center"><b><font size=-1><a href="db.pl?db=gallery&uid=default&view_records=1&ID=$dbman_field[0]">$dbman_field[1]</a></b><BR>$dbman_field[4]</font></td></tr></table></CENTER>|;
exit;
Cheers people!


Cheers!
Ben
------------
http://www.travel-experiences.com
Quote Reply
Re: Random Record Mod In reply to
I would think adding something like prior to your print statement may do the trick?

if ($approved eq "yes") {

print statement here

}

Of course changing the field name and valid option to match your database field values.

Hope this works

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Random Record Mod In reply to
I have a problem with this, if $approved is not checked the sript print nothing, I think that the correct is that the script search for other with $approved checked.

Quote Reply
Re: Random Record Mod In reply to
Did you put the code right below # Display Section:?

How do you have your approval field setup as a checkbox with only 1 option or as a radio field so that it is either yes or no?

I guess I'm not understanding why it's not working.

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Random Record Mod In reply to
Thanks LoisC, the mod found well, but for example:

I like display only the records with the second field checked.

record 1 have the field 2 checked
record 2 not have the field 2 checked

if the random mod select the record 1 the page display the record, but if the selected is record 2 the page don't display records, and I have an empty space in my page. The correct is display the record 1 or other with the field 2 checked.

Sorry for my English

Quote Reply
Re: Random Record Mod In reply to
Have anybody the solution for this problem?

Quote Reply
Re: Random Record Mod In reply to
This being a SSI solution, is it still possible to run within "DB Man" pages? i e to call it from within html.pl.

Thanks!