I could be wrong about this but I would think that you would want your
date_calc subroutine to just return a value and you would put that value
into your document where ever.
Brian Warn wrote:
>My apologies to those who've already seen this on the mysql list.
>Traffic is slow there today, so I'm hoping someone on this list has some
>ideas ...
>
>----------
>
>
>
>Hello, I need some advice regarding a scrolling list that I've built
>from a query. I can generated the scrolling list just fine, but when I
>try to put the subroutine within a table (cell), all I get is a hash
>reference:
>
>---------------------------------+---------+
>Date | column |
>---------------------------------+---------+
>date_calc(DBI::db=HASH(0xfdd40)) + 2 |
>---------------------------------+---------+
>
>Code for above output:
>
>print start_form (-method => "post", -action => url ());
>print "<table align=\"center\" border=\"1\" cellspacing=\"0\">";
>print "<tr><td>Date</td><td>column</td></tr>";
>print "<tr><td>date_calc($dbh)</td><td>2</td></tr>";
>print "</table>";
>print end_form ();
>
>Now, if I break apart the line that generates the above, I get the
>scrolling list to appear properly, but it doesn't appear in the first
>cell, it appears above the table. I get a '1' which indicates I believe
>that the subroutine returned a true value:
>
>(scrolling list appears here)
>-------+---------+
>Date | column |
>-------+---------+
>1 + 2 |
>-------+---------+
>
>Code for above output:
>
>print start_form (-method => "post", -action => url ());
>print "<table align=\"center\" border=\"1\" cellspacing=\"0\">";
>print "<tr><td>Date</td><td>column</td></tr>";
>print "<tr><td>" . date_calc($dbh) . "</td><td>2</td></tr>";
>print "</table>";
>print end_form ();
>
>Please advise what I should do to correct this. BTW, the subroutine I'm
>using for the above is as follows:
>
>sub date_calc {
> $dbh = shift;
> ($sth, $stmt);
> $stmt = qq { select distinct When from rCam order by When desc
>};
> $sth = $dbh->prepare ($stmt);
> $sth->execute ();
> print "<select name=\"dates\">";
> while ($row = $sth->fetchrow_hashref ()){
> push (@date_ary,$row->{When});
> }
> $sth->finish ();
> foreach $elt (@date_ary){
> print "<option>$elt</option>\n";
> }
> print "</select>\n";
>}
>
>Thanks,
>Brian
>
>
>
--
Brian Avis
SEARHC Medical Clinic
Juneau, AK 99801
(907) 463-4049
Have a nice diurnal anomaly!