OK. I'm feeling a little frustrated, and stupid. Let me see if I can review things clearly and logically. Sorry if I'm sounding repetitious, and for the length of this post. I'm trying to reason this though as clearly as I can.
I want to have a url that when clicked returns a single random record in long form (with the image).
I'm using the long/short mod, and the file-upload mod.
In order to get a record, one must perform as search; the showing of one or more records, in long or short form are the results of a query, and it's being processed though a sub rotine in html.pl
A query is performed by passing parameters to the sub query routine in db.cgi, via a url, or form action such as
Code:
&city=Brampton ...&View+Records (tells the db which html subroutine to push it through)
Now, the snippet
Code:
.
.
.
@values = &split_decode($line);
# Random sort
if ($in{'random'})
{
srand();
$values[11]=int(rand(1000)) + 1;
$in{'sb'} = 11;
}
Says "If the query string contains 'random" make the sort order random.
Therefor, when one want a group of records returned in a random order, one uses a url that contains
Code:
&city=Brampton&sb=11 (sorting by the field that is random)
The above, will return every record matching &city=Brampton in a random order, sorted by the values of field #11
but it will choose the first record, always.
One would think that everytime this query is performed, that because the sort order is different, that the first record would change everytime. This doesn't seem to be the case.
So my next move is/was to include the following code, under the sub html_home page. This is the routine that when you use no parameters in a url, that will bring you to the log in screen. I did this because I thought that the original poster (see above conversations) had it working. It don't.
Code:
# Get random record
$in{$db_key} = "*";
$in{'mh'} = 1; # change this to the number of records you want to show
$in{'random'} = 1; # Did I forget this before?
my ($status, @hits) = &query("view");
my ($numhits) = ($#hits+1) / ($#db_cols+1);
# Print out record
if ($status eq "ok") {
for (0 .. $numhits - 1) {
print "<P>";
&html_record_long(&array_to_hash($_, @hits));
}
}
Brain flash! Because I need it to return a full record, with an image, I must put it under sub html_record, under
Code:
$long_url = "$db_script_url?$long_url&nh=$record_number&mh=1";
This is the only place that will generate a link that will properly display an image in the long record form. I don't mind sending them though the short form first.
Current Results: If I do a regular search, I get all the results returned, but with a long form record above every short record.
If I understand the this correctly
Code:
# Get random record
$in{$db_key} = "*";
$in{'mh'} = 1; # change this to the number of records you want to show
$in{'random'} = 1; # Did I forget this before?
my ($status, @hits) = &query("view");
my ($numhits) = ($#hits+1) / ($#db_cols+1);
the above says: [some value (what is $in ?)] equals any content of the field set as the database key field, max hits = 1, [something] random = 1 and use the "view" subroutine of sub query. take the results and...
Code:
# Print out record
if ($status eq "ok") {
for (0 .. $numhits - 1) {
print "<P>";
&html_record_long(&array_to_hash($_, @hits));
}
}
if permissions say it's OK for me to see a record, for the amount of times in Max Hits (1 in this case), print <p> then the contents of what's in the long form.
Here's where I get lost: How do I actually implement this? Where do I put it so that I can through a url bring it up in the long form with the image (from file-upload) showing correctly, and what does the URL I want look like?