priyank Posted April 18, 2009 Share Posted April 18, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/154593-xhtml-strict-php/ Share on other sites More sharing options...
.josh Posted April 18, 2009 Share Posted April 18, 2009 does showPictures.php dynamically generate the picture? Quote Link to comment https://forums.phpfreaks.com/topic/154593-xhtml-strict-php/#findComment-812943 Share on other sites More sharing options...
priyank Posted April 18, 2009 Author Share Posted April 18, 2009 showPictures.php uses mysql database. Quote Link to comment https://forums.phpfreaks.com/topic/154593-xhtml-strict-php/#findComment-812947 Share on other sites More sharing options...
.josh Posted April 18, 2009 Share Posted April 18, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/154593-xhtml-strict-php/#findComment-812951 Share on other sites More sharing options...
priyank Posted April 18, 2009 Author Share Posted April 18, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/154593-xhtml-strict-php/#findComment-812959 Share on other sites More sharing options...
.josh Posted April 18, 2009 Share Posted April 18, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/154593-xhtml-strict-php/#findComment-812961 Share on other sites More sharing options...
priyank Posted April 18, 2009 Author Share Posted April 18, 2009 so if I combine php and html both i dont have to use action="showPictures.php" in <form> Quote Link to comment https://forums.phpfreaks.com/topic/154593-xhtml-strict-php/#findComment-812964 Share on other sites More sharing options...
.josh Posted April 18, 2009 Share Posted April 18, 2009 nope. you can make it blank and it will just reload the page. I don't know if that would ruin your "strict" html though..you should probably specify the page name to comply with that, if applicable. Quote Link to comment https://forums.phpfreaks.com/topic/154593-xhtml-strict-php/#findComment-812971 Share on other sites More sharing options...
Daniel0 Posted April 18, 2009 Share Posted April 18, 2009 You could also use Javascript to update it without refreshing. Quote Link to comment https://forums.phpfreaks.com/topic/154593-xhtml-strict-php/#findComment-812998 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.