Hello, i have a page where people can upload picture and so on and my php code loads the picture from /img/ folder from an uniqe ID the picture was given in the database and saved with. now when i view the uploaded pictures in firefox they are shown just fine firefox Example: [photo 1] [photo 2] [photo 3] but when i view them in internet explorer they are on the other hand shown as bellow and i wonder why, and if anyone know how to solve this :/ IE example: [photo 1] [photo 2] [photo 3]
how does the code look like when you view the source code in explorer? do you have the images in table or something?
PHP would have nothing to do with it. Its a server side language and not a client side language. There must be some problems with your layout.
this is the only code i use <? $MYSQL_HOST = 'test'; $MYSQL_USER = 'test'; $MYSQL_PASSWORD = 'test'; $MYSQL_DATABASE = 'test'; mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD); mysql_select_db($MYSQL_DATABASE); $res = mysql_query('SELECT *,unix_timestamp(tstamp) as utstamp FROM img ORDER BY tstamp DESC LIMIT 6'); echo '<table cellspacing="3" cellpadding="1" border="2"><tr>'; while ($row = mysql_fetch_assoc($res)) { $row['message'] = substr($row['message'],strpos($row['message'],' ')); // $row['message'] = substr($row['message'],strpos($row['message'],' ')); if ( file_exists('img/' . $row['id'] . '.jpeg') ) { $row['picture'] = 'img/' . $row['id'] . '.jpeg'; } else $row['picture'] = ''; if ( $row['picture'] != '' ) { echo '<a href="show.php?id=' . $row['id'] . '">'; echo '<img width="125" src="' . $row['picture'] . '"></a>'; } echo '</td>'; echo '</tr>'; } echo '</table>'; ?> </p> Code (markup):
You really should run HTML through a checker before putting it up on your website. Your code is not generating valid HTML. It should probably read: echo '<table cellspacing="3" cellpadding="1" border="2"><tr>'; while ($row = mysql_fetch_assoc($res)) { $row['message'] = substr($row['message'],strpos($row['message'],' ')); // $row['message'] = substr($row['message'],strpos($row['message'],' ')); if ( file_exists('img/' . $row['id'] . '.jpeg') ) { $row['picture'] = 'img/' . $row['id'] . '.jpeg'; } else $row['picture'] = ''; if ( $row['picture'] != '' ) { echo '<td><a href="show.php?id=' . $row['id'] . '">'; echo '<img width="125" src="' . $row['picture'] . '"></a></td>'; } } echo '</tr></table>'; ?> Code (markup): You were not starting and ending the table data segments of the HTML mark up and you were ending the table row on every loop. You only want to end it once to hope get the effect you seek.
try this echo "<table cellspacing=\"3\" cellpadding=\"1\" border=\"2\"><tr>"; while ($row = mysql_fetch_assoc($res)) { echo "<td>"; $row['message'] = substr($row['message'],strpos($row['message'],' ')); if ( file_exists('img/' . $row['id'] . '.jpeg') ) { $row['picture'] = 'img/' . $row['id'] . '.jpeg'; } else $row['picture'] = ''; if ( $row['picture'] != '' ) { echo '<a href="show.php?id=' . $row['id'] . '">'; echo '<img width="125" src="' . $row['picture'] . '"></a>'; } echo "</td>"; } echo "</tr></table>"; PHP: i think u miss add <td>
thanks that fixed the imiage problem with IE... but now every "background="img/meny.jpg" i had on the page stoped loading in IE insteed but works in firefox example, when i added the code above, the code bellow wont show up in IE but shows in Firefox. it's placed both at the end and before the php code. </p> <div align="center"> <table border="0" "> <table id="table3" border="0" background="img/meny.jpg" cellpadding="0" cellspacing="0" height="62" width="863" id="table2"> <tr> <td align="center"> <b><font size="2" color="#FFFFFF"> test <br> Beta 1.0 | <?php $mtime = explode(' ', microtime()); $totaltime = $mtime[0] + $mtime[1] - $starttime; printf('Page loaded in %.3f seconds.', $totaltime); ?></font></b></td> </tr> </table> </div> Code (markup):