images into html tables

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
pachox
Forum Newbie
Posts: 23
Joined: Sun Aug 17, 2003 7:14 am

images into html tables

Post 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.
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post 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>";
}
pachox
Forum Newbie
Posts: 23
Joined: Sun Aug 17, 2003 7:14 am

Post by pachox »

parse error, unexpected T_STRING, expecting ',' or ';' in ........
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post by delorian »

It should be like this, my mistake, but you should notice this.

Code: Select all

echo "<td><img src="".$riga['picfile'].""></td>";
pachox
Forum Newbie
Posts: 23
Joined: Sun Aug 17, 2003 7:14 am

Post by pachox »

well works fine now. thanks so much

how should i do to avoid printing empty columns that the scripts find in db?
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post 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
pachox
Forum Newbie
Posts: 23
Joined: Sun Aug 17, 2003 7:14 am

Post 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>";
pachox
Forum Newbie
Posts: 23
Joined: Sun Aug 17, 2003 7:14 am

Post by pachox »

this "=" should not be, ok

$riga=['cognome']!=NULL
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post 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.
pachox
Forum Newbie
Posts: 23
Joined: Sun Aug 17, 2003 7:14 am

Post 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?
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post 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
Post Reply