Jump to content

syntax help: image in html table using php


dm404

Recommended Posts

Hi everyone,

 

bit of a newbie. Basically I can display images from mysql using script such as

 


<img src=http://localhost/mywebsite/uploads/".$row['EventFlyer'] .">

 

However I can never get this to appear as an image in the below table.

 


echo '<tr>
  <td align="left"><a href="editevent.php?EventID=' . $row['EventID'] . '">Edit</a></td>
  <td align="left"><a href="deleteevent.php?EventID=' . $row['EventID'] . '">Delete</a></td>
  <td align="left">' . $row['EventName'] . '</td>
  <td align="left">' . $row['EventDate'] . '</td>
  <td align="left">' . $row['EventTime'] . '</td>
  <td align="left">' . $row['EventPrice'] . '</td>
  <td align="left">' . $row['EventDescription'] . '</td>
  <td align="left">' . $row['EventFlyer'] . '</td>
  
  </tr>

 

I know this only shows the file name, I've dabbled with inputting the image but it never works!

 

Any help would be fantastic!

corbin's right, notice how you have used "img src" before where you say it works, but not later on where you say it doesn't.

 

img src is short for "image source" - if you don't tell the browser it's an image then it won't try and display it as one.

The query is working ok as all the other fields are being populated a ok. Its just displaying the image within that's confusing me.

 

echo '<table align="center" cellspacing="0" cellpadding="7">
<tr>

<td align="left"><b>Edit</b></td>
<td align="left"><b>Delete</b></td>
<td align="left"><b>Name</b></td>
<td align="left"><b>Date</b></td>
<td align="left"><b>Time</b></td>
<td align="left"><b>Price</b></td>
<td align="left"><b>Description</b></td>
<td align="left"><b>Flyer</b></td>

</tr>

';

// Fetch and print all the records

while ($row = mysql_fetch_array($result7, MYSQL_ASSOC)) {

echo '<tr>
  <td align="left"><a href="editevent.php?EventID=' . $row['EventID'] . '">Edit</a></td>
  <td align="left"><a href="deleteevent.php?EventID=' . $row['EventID'] . '">Delete</a></td>
  <td align="left">' . $row['EventName'] . '</td>
  <td align="left">' . $row['EventDate'] . '</td>
  <td align="left">' . $row['EventTime'] . '</td>
  <td align="left">' . $row['EventPrice'] . '</td>
  <td align="left">' . $row['EventDescription'] . '</td>
  <td align="left"><img src=http://localhost/mywebsite/uploads/".$row['EventFlyer'] ."></td>

  
  </tr>

  
  
  ';
  
  }
  
  echo '</table>';
  
  
  mysql_free_result ($result7); // Free up the resources

 

Cheers for the help it is much appreciated

 

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.