www.webdeveloper.com
Results 1 to 3 of 3

Thread: Replace Image

  1. #1
    Join Date
    Dec 2011
    Posts
    39

    Replace Image

    Sir, I am using these codes

    PHP Code:
    <?php
    require_once("connect.php");

    if(isset(
    $_POST ['display']))
    {
        
    $sql="select * from photo where id=2 ";
        
    $query=mysqli_query($con,$sql);
        while(
    $row=mysqli_fetch_array($query))
        {
        
    $image=$row ['picture'];
        echo 
    '<img src="upload/'.$image.'" width="50" height="50">';
        }
    }

    ?> 

    <html>
    <head>
    <style type="text/css">

    html {
    overflow:auto;
    }

    body{
    background-color:#e7f4fe;
    }

    #container {
    margin: auto;
    position:absolute;
    top:0;left:0;right:0;bottom:0;
    background-color:#CFC;
    padding:10px;
    overflow:auto;
    width:200px;
    height:200px;
    border:1px solid #6CF;
    text-align:center;
    }
    </style>

    </head>

     <body>
     <div id="container">
       <form action="" method="post"
     enctype="multipart/form-data">
         <img id="photo" width="100" height="100" src="photo96.png" style="text-align: center;" /><br />
         <br>
         <input type="submit"  name="display" value="Display">
       </form>
     </div>
     </body>
     
     </html>

    It work fine, but when I press display button then image from table is shown in top left corner of the screen but i want to display it in div like this:

    http://i39.tinypic.com/2yyo02f.jpg

    Actually I am trying to replace existing image with new one.

    Please help

  2. #2
    Join Date
    Oct 2013
    Location
    3rd planet from the sun
    Posts
    165
    might have better luck in the php section

  3. #3
    Join Date
    Jan 2014
    Posts
    1

    Thumbs up do like this

    Quote Originally Posted by tqmd1 View Post
    Sir, I am using these codes

    PHP Code:
    <?php
    require_once("connect.php");

    if(isset(
    $_POST ['display']))
    {
        
    $sql="select * from photo where id=2 ";
        
    $query=mysqli_query($con,$sql);
        while(
    $row=mysqli_fetch_array($query))
        {
        
    $image=$row ['picture'];
        echo 
    '<img src="upload/'.$image.'" width="50" height="50">';
        }
    }


    ?> 

    <html>
    <head>
    <style type="text/css">

    html {
    overflow:auto;
    }

    body{
    background-color:#e7f4fe;
    }

    #container {
    margin: auto;
    position:absolute;
    top:0;left:0;right:0;bottom:0;
    background-color:#CFC;
    padding:10px;
    overflow:auto;
    width:200px;
    height:200px;
    border:1px solid #6CF;
    text-align:center;
    }
    </style>

    </head>

     <body>
     <div id="container">
       <form action="" method="post"
     enctype="multipart/form-data">
         <img id="photo" width="100" height="100" src="photo96.png" style="text-align: center;" /><br />
         <br>
         <input type="submit"  name="display" value="Display">
       </form>
     </div>
     </body>
     
     </html>

    It work fine, but when I press display button then image from table is shown in top left corner of the screen but i want to display it in div like this:

    http://i39.tinypic.com/2yyo02f.jpg

    Actually I am trying to replace existing image with new one.

    Please help

    Something like this...

    if(isset($_POST ['display']))
    {
    $sql="select * from photo where id=2 ";
    ...
    $image=$row ['picture'];
    $image="upload/" . $image;
    }
    else
    {
    $image="photo96.png"
    }
    Then in your HTML...simply echo $image where the source attribute is located.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles