Page 1 of 1

images into html tables

Posted: Sun Aug 17, 2003 7:14 am
by pachox
i have a while that reads like this:

while ($riga = mysql_fetch_array($result)) {
echo "<tr class=`GridRow`
onmouseover=`this.className='GridMOverRow'`
onmouseout=`this.className='GridRow'` id=`ggg`>\n";
echo "\t<td>" .$cognome = $riga['cognome']."</td>\n";
echo "\t<td>" .$nome = $riga['nome']."</td>\n";
echo "\t<td>" "<img src=".$picfile = $riga['picfile'].">""</td>\n";

now pic file is a jpg img. so how should i declare the img src to view pics in html tables? actually (of course) i get simply the file name.

Posted: Sun Aug 17, 2003 8:27 am
by delorian
First of all, why are you using flat file newline and tab special chars \n \t. Your code should look something like this:

Code: Select all

while ($riga = mysql_fetch_array($result)) { 
    echo "<tr class="GridRow"
onmouseover="this.className='GridMOverRow'" 
onmouseout="this.className='GridRow'" id="ggg">"; 
echo "<td>" .$riga['cognome']."</td>"; 
echo "<td>" .$riga['nome']."</td>"; 
echo "<td>"<img src="".$riga['picfile'].""></td>"; 
echo "</tr>";
}

Posted: Sun Aug 17, 2003 8:57 am
by pachox
parse error, unexpected T_STRING, expecting ',' or ';' in ........

Posted: Sun Aug 17, 2003 9:08 am
by delorian
It should be like this, my mistake, but you should notice this.

Code: Select all

echo "<td><img src="".$riga['picfile'].""></td>";

Posted: Sun Aug 17, 2003 9:14 am
by pachox
well works fine now. thanks so much

how should i do to avoid printing empty columns that the scripts find in db?

Posted: Sun Aug 17, 2003 9:19 am
by delorian
You should check if something is empty, if not print it.

Code: Select all

while ($riga = mysql_fetch_array($result)) { 
if($riga['picfile']!=NULL && $riga['nome']!=NULL && $riga=['cognome']!=NULL) {
    echo "<tr class="GridRow"
onmouseover="this.className='GridMOverRow'" 
onmouseout="this.className='GridRow'" id="ggg">"; 
echo "<td>" .$riga['cognome']."</td>"; 
echo "<td>" .$riga['nome']."</td>"; 
echo "<td><img src="".$riga['picfile'].""></td>"; 
echo "</tr>";
}
}
Another tip: don't have empty recorde in your table, it's not professional, hehe :D

Posted: Sun Aug 17, 2003 9:29 am
by pachox
another parse error

Parse error: parse error, unexpected '[' in ...


and to set img size why this doe not work?
echo "<td><img width="50%" height="50%" src=\"images/medici/".$riga['picfile']."\"></td>";

Posted: Sun Aug 17, 2003 9:56 am
by pachox
this "=" should not be, ok

$riga=['cognome']!=NULL

Posted: Sun Aug 17, 2003 11:33 am
by delorian
I wrote $riga=, hmm, that's the way when you write something in a rush. :D

Code: Select all

while ($riga = mysql_fetch_array($result)) { 
if($riga['picfile']!=NULL && $riga['nome']!=NULL && $riga['cognome']!=NULL) { 
    echo "<tr class="GridRow" 
onmouseover="this.className='GridMOverRow'" 
onmouseout="this.className='GridRow'" id="ggg">"; 
echo "<td>" .$riga['cognome']."</td>"; 
echo "<td>" .$riga['nome']."</td>"; 
echo "<td><img src="".$riga['picfile'].""></td>"; 
echo "</tr>"; 
} 
}
But if you want to set size of the image you can't just put 50% value, HTML doesn't get it. 50% of what :?: I you want to get the size read the php manual for getimagesize() function - it has all what you need.

Posted: Sun Aug 17, 2003 5:13 pm
by pachox
ok, all this works fine.

say now i want to add a feature...
i'd like to get on mouseover a text field (say in paragraph, tables is better, or textarea) with a description of the activity.

hints?

Posted: Mon Aug 18, 2003 2:25 am
by delorian
I would say that you should search for the solution on one of the code libraries over the net. It's very easy to do it. If you want, you can see how it is done on http://studio-x.pl or http://tmad.skylinedstudio.com - you won't understand the language but the code you will :D