perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Angus Lees <...@inodes.org>
Subject Re: Display using array ref of NULLs in dynamic table
Date Mon, 27 Jan 2003 06:48:24 GMT
At Fri, 24 Jan 2003 16:54:24 +1100, Jim Hall wrote:
> After selecting a set of data using the following:
>    
>    ...
>    $dat = $sth_rte_sel -> fetchall_arrayref;
>    ...
> 
> and then attempting to display in a table:
> 
> <tr bgcolor="[+ $row % 2 == 0?'#ffffc6':'#ffe7c6' +]">
>     <td>[+ $dat->[$row][1] +]</td>
>     <td>[+ $dat->[$row][3] +]</td>
>     <td>[+ $dat->[$row][4] +]</td>
>     <td>[+ $dat->[$row][5] +]</td>
>     <td>[+ $dat->[$row][6] +]</td>
>     <td ALIGN=Center><INPUT TYPE=Submit Name="TEdit[+$dat->[$row][2]+]"
> Value=Ed
> it></TD>
> </tr>
> 
> I'm finding that if a record contains a field with a NULL value then
> the whole record is not displayed.
> Is there a way of turning off this behaviour?

you could turn it off by setting $tabmode = 20 and then $maxrow =
@$dat, but thats too hard (and likely to upset other Embperl pages).

typically you work around it by doing [+ $dat->[$row][1] || '' +] in
places you expect to find a NULL.  obviously you can't do this for
every column or the row loop will never exit.

if you may have NULL's on any cell (or don't know what to expect) then
you have to do each row separately like so:

<tr>
  [- $r = $dat->[$row] -]
  <td>[+ $r->[1] +]</td>
  <td>[+ $r->[3] +]</td>
</tr>

and if you're going to do each row separately, then you may as well
not keep all the rows in memory (unless you need to use the results
somewhere else):

<tr>
  [- $r = $sth_rte_sel->fetch -]
  <td>[+ $r->[1] +]</td>
  <td>[+ $r->[3] +]</td>
</tr>


-- 
 - Gus

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message