can any help with this code pics not showing

Discussion in 'PHP' started by dougvcd, Mar 17, 2008.

  1. #1
    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:

     
    dougvcd, Mar 17, 2008 IP
  2. jmhyer123

    jmhyer123 Peon

    Messages:
    542
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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 ;)
     
    jmhyer123, Mar 17, 2008 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    EDIT: Too late...

    Back to the basics.... The HTML <img> tag is wrong.
     
    nico_swd, Mar 17, 2008 IP
  4. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #4
    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
     
    kmap, Mar 17, 2008 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    I guess 2 times the same answer wasn't enough yet, huh?
     
    nico_swd, Mar 17, 2008 IP
  6. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #6
    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
     
    ezprint2008, Mar 18, 2008 IP
  7. dougvcd

    dougvcd Peon

    Messages:
    267
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    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
    :confused:
     
    dougvcd, Mar 18, 2008 IP
  8. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #8
    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?
     
    nico_swd, Mar 19, 2008 IP