Subject | Re: [firebird-php] Formatting blobs into tables |
---|---|
Author | Robin Davis |
Post date | 2006-01-23T23:47:27Z |
Lester Caine wrote:
and a very nice program it is. I'm taking a look at smarty, but I am a
beginner at all this and it's gonna take me a little time to get my head
round it.
Now, I know this is probably dreadful practice for people who know what
they're doing, but what I have had to do is convert the blob fields into
varchar fields and then fetch the info' with:
<?
$dbh = ibase_connect('C:/data/artists.fdb','*****','*****','ISO8859_1',0,1);
$sql="SELECT CHARACTERS FROM men WHERE CHARACTERS IS NOT NULL ORDER BY
LASTNAME ASC";
$result=ibase_query($sql)or die(ibase_errcode());
$num_cols=2;
while ($row=ibase_fetch_assoc($result)){
$img[]=$row['CHARACTERS'];
}
while(count($img)%$num_cols!=0){
$img[]='empty_cell';
}
echo "<center><table border=1 cellpadding=1 cellspacing=10 width=720>";
for($i=0;$i<count($img);$i++){
$content=($img[$i]=='empty_cell')?' ':''.$img[$i].'';
if($i%$num_cols==0){
echo "<tr><td width=360>$content</td>";}
elseif($i%$num_cols==$num_cols-1){
echo "<td width=360>$content</td></tr>\n";}
}
echo "</table></center>\n";
ibase_free_result($result);
ibase_close($dbh);
?>
I include this code inside an shtml file in order to get the results
displayed. Is this VERY bad practice? Probably. :-(
Rob Davis
>Robin Davis wrote:Thanks for the reply, Lester. Yes, I do indeed have and use ibwebadmin,
>
>
>
>>Hi,
>>
>>I can retrieve stored html with the following code, but I can't output
>>it into an html table with two columns. Could anybody [point me in the
>>right direction to learn how to?
>>
>><?
>>$dbh =
>>ibase_connect('C:/data/artists.fdb','*****','******','ISO8859_1',0,1);
>>$sql="SELECT COMPILATION FROM WOMEN ORDER BY LASTNAME ASC";
>>$result=ibase_query($sql)or die(ibase_errcode());
>>
>>while ($row=ibase_fetch_row($result)){
>> $img[]=ibase_blob_echo($row[0]);
>>}
>>
>>ibase_free_result($result);
>>ibase_close($dbh);
>>
>>?>
>>
>>Thanks a lot,
>>
>>Rob Davis
>>(Using Apache/2.0.54 (Win32) PHP/5.1.1 and Firebird 2 (Beta) on an XP
>>machine)
>>
>>
>Nice setup
>
>This is a 'how long is a piece of string' type question.
>Without knowing what the rest of your page generation code looks like it
>is difficult.
>A good start for building tables from data is the rs2html function in
>ADOdb http://phplens.com/lens/adodb/docs-adodb.htm#rs2html
>The code will show you how to do it, but I suspect you need to decide
>how you are going to build pages, and something like smarty
>http://smarty.php.net/ provides a template framework.
>
>Any of the php code sample site will provide other examples, and even
>ibWebAdmin has a nice format for that http://www.ibwebadmin.net/ you do
>have THAT tool already - don't you :)
>
>
>
and a very nice program it is. I'm taking a look at smarty, but I am a
beginner at all this and it's gonna take me a little time to get my head
round it.
Now, I know this is probably dreadful practice for people who know what
they're doing, but what I have had to do is convert the blob fields into
varchar fields and then fetch the info' with:
<?
$dbh = ibase_connect('C:/data/artists.fdb','*****','*****','ISO8859_1',0,1);
$sql="SELECT CHARACTERS FROM men WHERE CHARACTERS IS NOT NULL ORDER BY
LASTNAME ASC";
$result=ibase_query($sql)or die(ibase_errcode());
$num_cols=2;
while ($row=ibase_fetch_assoc($result)){
$img[]=$row['CHARACTERS'];
}
while(count($img)%$num_cols!=0){
$img[]='empty_cell';
}
echo "<center><table border=1 cellpadding=1 cellspacing=10 width=720>";
for($i=0;$i<count($img);$i++){
$content=($img[$i]=='empty_cell')?' ':''.$img[$i].'';
if($i%$num_cols==0){
echo "<tr><td width=360>$content</td>";}
elseif($i%$num_cols==$num_cols-1){
echo "<td width=360>$content</td></tr>\n";}
}
echo "</table></center>\n";
ibase_free_result($result);
ibase_close($dbh);
?>
I include this code inside an shtml file in order to get the results
displayed. Is this VERY bad practice? Probably. :-(
Rob Davis