To display picture from MYSQL database in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kivaniya
    New Member
    • May 2013
    • 2

    #1

    To display picture from MYSQL database in php

    want to display a table with Name, Age and picture from images folder - need code to insert image - field called Picture in MYSQL Database


    Code:
    <?php
    $con = mysql_connect("localhost","db","pass");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
     
    mysql_select_db("three_rivers", $con);
     
    $result = mysql_query("SELECT * FROM TABLE2");
     
    echo "<table border='1'>
    <tr>
    <th>Name</th>
    <th>Age</th>
    <th>Picture</th>
    </tr>";
     
    while($row = mysql_fetch_array($result))
      {
      echo "<tr>";
      echo "<td>" . $row['Name'] . "</td>";
      echo "<td>" . $row['Age'] . "</td>";
      echo '<td>' . "<a href='['Picture']<img  src='$[Picture]'  alt='$[Picture]'  width='220' height='220'></a>" . '</td>';
     
     echo "</tr>";
      }
    echo "</table>";
     
    mysql_close($con);
    ?>
    Last edited by Rabbit; May 20 '13, 02:00 PM. Reason: Please use code tags when posting code.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    Why do you use $row in '$row['Age']',

    and not in: '"<a href='['Picture']' ????

    and why do you not use the [CODE/] tags, to post your code?

    Comment

    • kivaniya
      New Member
      • May 2013
      • 2

      #3
      I don't know but if you dont have a solution why post? I'm a newbie to php.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Luuk has the solution. They're just trying to guide you to the answer by showing you the inconsistency in your code.

        Comment

        Working...