-2

I tried to generate a html table with only 2 cells using PHP. First table cell is an image and second cell has another table. I can put the data which I want in second cell (in table format). But failed to display image in first table cell.

Searching the forum showed some solved echo related to issue, but it couldn’t solve my problem.

Here is the code I used,

if(array_filter($values2))
{

     echo "<!DOCTYPE html>";
     echo "<html>";
     echo "<head>";
     echo "<table>";

     echo "<tr>";
     echo "<td>";
     echo "<img src = treedir . '/' .  $tffam;?>"; //my problem here
     echo "</td>";              

     echo "<td>";
     //a table generating code and it  works fine
     echo "</td>";
     echo "</tr>";
     echo "</body>";
     echo "</html>"; 

}
Adrian Cid Almaguer
  • 7,815
  • 13
  • 41
  • 63
  • possible duplicate of [How to combine two strings together?](http://stackoverflow.com/questions/8336858/how-to-combine-two-strings-together) – Rizier123 Feb 24 '15 at 06:00

2 Answers2

1

The problem was with the " and the '. Try with this:

  echo "<img src='/treedir/" .  $tffam . "'/>";
Adrian Cid Almaguer
  • 7,815
  • 13
  • 41
  • 63
  • I tried the command which you provided. But still image cant be displayed. $tffam hold the exact image name with extension too@Adrian –  Feb 24 '15 at 06:19
  • I edit the code, but can you tell me the value of $tffam and check if really do you have the image in your /treedir/ – Adrian Cid Almaguer Feb 24 '15 at 06:31
  • value of $tffam is ABI3VP1.png. There is a png file in the same name in treedir. I double checked it. Or is there any problem with absolute path? /var/www/html/sn/treedir is the full path. But the result is same@Adrian –  Feb 24 '15 at 06:42
  • and where are located your page? in /var/www/html/sn ? – Adrian Cid Almaguer Feb 24 '15 at 06:43
  • It worked. Thanks for spending time to look into the issue @Adrian –  Feb 24 '15 at 06:47
  • @Snijesh if it worked check at correct my answer ;-) – Adrian Cid Almaguer Feb 24 '15 at 06:51
1

you can try this :

echo "<img src='treedir/$tffam' alt='some text' >";