kirigwajo Posted January 14, 2011 Share Posted January 14, 2011 i have a database named "child" a table "jpg" with column names; pid, title and imgdata. i have managed to get images into the database but now i want to be able to call the images using "title" The code i have displays the image last added to the Mysql database. This is the code that where i have to enter the variable for "title" to display the image. <html> <body bgcolor=#afd1f4> <table border='1' bgcolor=#7991d4 frame=lhs cellpadding="4" width=100%> <tr bgcolor=#cbe0ac ><td><font face='Vinque'><B>SEARCH FOR A CHILD PHOTO</B></TR> <tr><td><p align="center"><font size="4" face="Vinque"> <form action="jpgshow.php" method="POST"> <p align="center"><font size="4" face=""> CHILD NAME:<br/> <input type="text" name="title" size="30" /><br/> <div align="center"><input type="submit" name="submit" value= "Find" /> <input type="reset" name="Clear" value= "Clear" /> </div> </form ><legend><table border='1' bgcolor=d4ecfb frame=lhs cellpadding="4" width=100%><tr><td> <title>Search Results</title></head><h4><p align="center"><font size="5">SEARCH RESULTS</font></h4></p> <br/> <?php $pid=$_POST['pid']; $title=$_POST['title']; $imgdata=$_POST['imgdata']; $server = 'localhost'; $dbuser="root"; $dbpasswd=""; // Make a MySQL Connection mysql_connect($server , $dbuser , $dbpasswd) or die(mysql_error()); mysql_select_db("child") or die(mysql_error()); // Get all the data from the "jpg" table $bytes = $row[imgdata]; echo $imgdata; print $bytes; $select=("select pid,title from jpg where title='$title'"); $result=mysql_query($select); while($info=mysql_fetch_array($result)){ echo ' </table>'; } ?> <img src="jpgshow.php?pid=<?php echo $pid ?>"> <form action="child.html" method="POST"> <div align="left"><input type="submit" name="submit" value=" Back" /> </legend></body></html> this is the code for that displays the image last entered in database. <?php $username="root"; $password=""; $database="child"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die("<b>Unable to specified database</b>"); $image = stripslashes($_REQUEST[title]); $gotten = @mysql_query("select * from jpg order by pid desc limit 1"); addslashes($image).".jpg\""; $row = @mysql_fetch_assoc($gotten); $imagebytes = $row[imgdata]; header("Content-type: image/jpeg"); print $imagebytes; ?> please help me. Quote Link to comment https://forums.phpfreaks.com/topic/224400-displaying-an-image-from-mysql-database-using-php/ Share on other sites More sharing options...
fenway Posted January 14, 2011 Share Posted January 14, 2011 What's not workign? Quote Link to comment https://forums.phpfreaks.com/topic/224400-displaying-an-image-from-mysql-database-using-php/#findComment-1159447 Share on other sites More sharing options...
kirigwajo Posted January 14, 2011 Author Share Posted January 14, 2011 The image i search for is not the image retrieved from database. it continuosly dispalys the same image. even when i change the search name. help please. thank u Quote Link to comment https://forums.phpfreaks.com/topic/224400-displaying-an-image-from-mysql-database-using-php/#findComment-1159508 Share on other sites More sharing options...
fenway Posted January 19, 2011 Share Posted January 19, 2011 Well, you're not using the data from the database. Quote Link to comment https://forums.phpfreaks.com/topic/224400-displaying-an-image-from-mysql-database-using-php/#findComment-1162131 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.