Jump to content

Recommended Posts

Following is my code for displaying image. I can see images which uses php file ,but it open in new window.

 

Since i have to use xhtml strict i cant use frame or iframe

How can i display image in same window, so when i change option from dropdown i can view image and dropdownbox.

 

thanks

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

 

<title></title>

 

 

 

</head>

<body>

 

 

 

<form action="showPictures.php" method="get">

      <fieldset>

              <select size="1" name="dropdown">

                    <option value="nothing" selected="selected">  </option>

                    <option value="1">Image1</option>

                    <option value="2">Image2</option>

                    <option value="3">Image3</option>

            </select>

       

            <input type="submit" value="Show" name="Submit"  />

      </fieldset>

</form>

 

 

 

 

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/154593-xhtml-strict-php/
Share on other sites

you want specific help, you need to give specific info.  You said that your form gets pics, using a php file. How? You say that your php file uses a database. how?  How are these pictures stored. How are they sent back to the client? if you want specific help, you need to give specific info.

Link to comment
https://forums.phpfreaks.com/topic/154593-xhtml-strict-php/#findComment-812951
Share on other sites

Here is a php file that is called.

 

$selectedImage = $_GET['dropdown'];

 

    // Performing SQL query

    $query = 'SELECT Image FROM tableImages where imageID = "'.$_GET['dropdown'].'"' ;

    $result = mysql_query($query) or die('Query failed: ' . mysql_error());

 

    // Printing results in HTML

 

while($row = mysql_fetch_array($result))

        {   

          $img = $row['Image'];

  echo "<img src='$img' />";

}

 

      // Free resultset

      mysql_free_result($result);

 

      // Closing connection

      mysql_close($link);

?>

 

html code

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

 

<title></title>

 

 

 

</head>

<body>

 

 

 

<form action="showPictures.php" method="get">

      <fieldset>

              <select size="1" name="dropdown">

                    <option value="nothing" selected="selected">  </option>

                    <option value="1">Image1</option>

                    <option value="2">Image2</option>

                    <option value="3">Image3</option>

            </select>

       

            <input type="submit" value="Show" name="Submit"  />

      </fieldset>

</form>

 

 

 

 

</body>

</html>

 

I search in google it says to use <object> instead of <iframe> but <object> does not have attribute called method,action

Link to comment
https://forums.phpfreaks.com/topic/154593-xhtml-strict-php/#findComment-812959
Share on other sites

You would just combine the two...this would be your showPictures.php. the form would call the same page its on.

 

<?php
$selectedImage = $_GET['dropdown'];

// Performing SQL query
$query = 'SELECT Image FROM tableImages where imageID = "'.$_GET['dropdown'].'"' ;
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

// Printing results in HTML
   
while($row = mysql_fetch_array($result))
{       
           $img = $row['Image'];
      $image = "<img src='$img' />";    
   }

      // Free resultset
      mysql_free_result($result);

       // Closing connection
      mysql_close($link);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title></title>



</head>
<body>


<?php echo $image; // put this wherever ?>

<form action="showPictures.php" method="get">
       <fieldset>
              <select size="1" name="dropdown">
                    <option value="nothing" selected="selected">  </option>
                    <option value="1">Image1</option>
                    <option value="2">Image2</option>
                    <option value="3">Image3</option>
             </select>
         
             <input type="submit" value="Show" name="Submit"  />
       </fieldset>
</form>




</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/154593-xhtml-strict-php/#findComment-812961
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.