am using this code to show details ina table with a pic at the end but not working cheers Doug echo "<table border='1' cellpadding='5'> <tr> <th>Name</th> <th>Contact</th> <th>Email</th> <th>Details</th> <th>Photo</th> </tr>"; //Puts it into an array while($row = mysql_fetch_array( $result )) { //Outputs the image and other data echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['contact'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "<td>" . $row['details'] . "</td>"; echo "<img src=http://lostpetsplymouth_zxq_net/pics/" . $row['pname'] . "</td>"; echo "</tr>"; } echo "</table>"; PHP:
Try this: echo "<table border='1' cellpadding='5'> <tr> <th>Name</th> <th>Contact</th> <th>Email</th> <th>Details</th> <th>Photo</th> </tr>"; //Puts it into an array while($row = mysql_fetch_array( $result )) { //Outputs the image and other data echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['contact'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "<td>" . $row['details'] . "</td>"; echo '<img src=\"http://lostpetsplymouth_zxq_net/pics/".$row['pname']."\" /></td>'; echo "</tr>"; } echo "</table>"; Code (markup): That should do it for you, if it doesn't let me know and I can take a deeper look at it, this is just off the top of my head
oops you did not close the angle bracket of img tag echo "<img src=\"http://lostpetsplymouth_zxq_net/pics/'.$row['pname'].'\"></td>'; this shd work Regards Alex
lol nico is right the whole image tag is wrong. _net (as opposed to) .net ? no single or double quotes on the tag (you saw you couldnt use double quotes as it would interfere with the PHP but you cant leave it blank. and the next thing you wouldve noticed is that you cant use single quotes either BECAUSE you use them on $row['pname'] what you'll have to do is make it double quotes. AND convert your $row variable to a variable name.. like this $bigfoot = $row['pname'] ; // called bigfoot for sheets and giggles. and then your image src tag like this. echo "<image src='http://lostpetsplymouth_zxq.net/pics/" . $bigfoot . "'></td>"; (assuming that your picture files will have their extensions of .jpg/ .gif/ etc already in tact from where youre fetching them from, if not you'll need to add the extension correctly to if its a .jpg or .gif ...which would be very anal ...so just include the extensions when stored ) strategize the use of single or double quotes. when you're in a predictament of having both single and double quotes in either variables or string URLs. then convert variables like $row['single_quote_excessive_use'] to $bigfoot lol of course it doesnt have to be $bigfoot, although i think it could catch on ..its just nobody would see it if its in your top level php code. would that make it similar to the real bigfoot? ..i dont know
thanks to all for help but i just cant get it to work any suggestions as to a better way of doing it cheers Doug
There's also missing an opening <td> tag in front of the <img> tag. If that doesn't work either, then there's nothing else we can do as the code is technically correct besides this. Perhaps your URLs are wrong, or the permissions of the files. Can you open the images by entering the URL in the address bar of your web browser?