images into html tables
Moderator: General Moderators
images into html tables
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.
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.
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>";
}It should be like this, my mistake, but you should notice this.
Code: Select all
echo "<td><img src="".$riga['picfile'].""></td>";You should check if something is empty, if not print it.
Another tip: don't have empty recorde in your table, it's not professional, hehe 
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>";
}
}I wrote $riga=, hmm, that's the way when you write something in a rush.
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.
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>";
}
}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 