Jump to content

[SOLVED] Image Tags


bmdsherman

Recommended Posts

Not with html alone.

 

Hmm, what about with php?

The code around the image is:

<?php
while($row = mysql_fetch_assoc($result)){  echo "<center>
<table border='0' cellspacing='2' cols='2' frame='void' rules='none'>
  <colgroup>
  <col width='350'>
  <col width='350'>
  <col width='350'>
  </colgroup>
  <tbody>

    <tr>
      <td><center><a href=profile.php?p={$row['id']}>{$row['fname']} {$row['lname']}</a></center></td>
      <td><center><a href=mailto:{$row['email']}>{$row['email']}</a></center></td>
      <td><center><img src={$row['img']}></center></td>
    </tr>
    </tbody>
</table>";
  }

Link to comment
https://forums.phpfreaks.com/topic/171091-solved-image-tags/#findComment-902286
Share on other sites

$src = (is_file($row['img'])) ? $row['img']: "somethingelse.jpg";
<td><center><img src={$src}></center></td>

 

You will have to play with that.

 

Also, you should be putting double quotes around your html attributes. So instead of:

 

<img src=something

 

you have

<img src="something"

Link to comment
https://forums.phpfreaks.com/topic/171091-solved-image-tags/#findComment-902292
Share on other sites

Also, you should be putting double quotes around your html attributes. So instead of:

 

<img src=something

 

you have

<img src="something"

 

Ya I know I'm cheating but I'm using double quotes for the php echo because variables aren't picked up in single quotes.

 

 

Thanks for your help!

Link to comment
https://forums.phpfreaks.com/topic/171091-solved-image-tags/#findComment-902293
Share on other sites

It's not a problem with cheating, it's a problem that your code won't work properly in some browsers. It also won't be valid.

 

You have a choice, either escape your quotes inside the double quotes:

 

echo "<img src=\"$row['img']\" />";

 

Or preferably exit out of your quotes and put in the value:

 

echo '<img src="' . $row['img'] . '" />';

 

The second one being more efficient when processing.

Link to comment
https://forums.phpfreaks.com/topic/171091-solved-image-tags/#findComment-902297
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.