rinteractive Posted December 27, 2007 Share Posted December 27, 2007 hey guys i am new to php , When i am retrieving the data from mysql table , the image is not displaying but it shows only the image name. The coding i have used for retrieving is given just below: <?php include ("../include/config.php"); $sql = "SELECT id, name, photo FROM member"; $results = mysql_query($sql) or die ("Err, Problem with the database....".mysql_error()); $num=1; while ($row = mysql_fetch_row($results)){ $id = $row[0]; $name = $row[1]; $photo = $row[2]; $display_str .= " <tr bgcolor=\"#FFFFFF\"> <td align=\"center\">$num</td> <td align=\"center\"><input type=\"radio\" name=\"id\" value=\"$id\"></td> <td align=\"center\">$name</td> <td align=\"center\">$photo</td> </tr>"; $num++; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Anti Corruption Intelligence Committee (ACIC) Admin Home</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="css/main.css" type="text/css" /> <script language="javascript" type="text/javascript"> <!-- function validate(action_type){ is_radio_checked=false; if (document.head.id.length){ no_of_radio=document.head.id.length; for (i=0;i < no_of_radio;i++){ if (document.head.id.checked == true){ is_radio_checked=true; break; } } } else{ if (document.head.id.checked) is_radio_checked=true;; } if (is_radio_checked == false){ alert("Please Select the Type") return false; } document.head.action_type.value = action_type; if (action_type == "edit"){ document.head.submit(); return true; } if (action_type == "delete"){ delete_confirm = confirm("IMPORTANT: Are you sure you want to delete? ALL the products inside this Family will be DELETED."); if(delete_confirm){ document.head.submit(); return true; } else{ return false; } } return false; } --> </script> </head> <body> <strong><h2 align="center">Select a <u>Members</u> to edit</h2></strong> <?php if ($msg == '1'){ ?> <center><big><font color="green"><strong>Your Changes Have Been Saved !!!</strong></font></big></center> <?php } if ($msg == '2'){ ?> <center><big><font color="green"><strong>Records Successfully Deleted !!!</strong></font></big></center> <?php } ?> <form name="head" action="head-action.php" method="post"> <table width="50%" align="center" cellpadding="2" cellspacing="1" class="TableBG" border="2"> <tr bgcolor="#FFFFFF"> <th class="BlueBG"><strong>#</strong></th> <th class="BlueBG"><strong>Select</strong></th> <th class="BlueBG"><strong>member</strong></th> <th class="BlueBG"><strong>Image</strong></th> </tr> <?php echo $display_str; ?> <tr bgcolor="#FFFFFF"> <td align="center" colspan="5"> <input type="button" name="edit" value="Edit Member" class="FormButton" onclick=validate("edit")> <input type="button" name="delete" value="Delete Member" class="FormButton" onclick=validate("delete")> <input type="hidden" value="" name="action_type"> </td> </tr> <tr bgcolor="#FFFFFF"> <td align="center" colspan="5" height="30"><a href="head-add.php"><b>Add Member</b></a></td> </tr> </table> </form> </body> </html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> </body> </html> Please anybody help me Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/83344-solved-retrieving-data-from-mysql-table-using-php/ Share on other sites More sharing options...
wolfrat Posted December 27, 2007 Share Posted December 27, 2007 Hmm, I'm not quite sure where your image tag was in there, but I'm guessing you want it in here: <tr bgcolor=\"#FFFFFF\"> <td align=\"center\">$num</td> <td align=\"center\"><input type=\"radio\" name=\"id\" value=\"$id\"></td> <td align=\"center\">$name</td> <td align=\"center\">$photo</td> If you just have the image name saved, you should do: <tr bgcolor=\"#FFFFFF\"> <td align=\"center\">$num</td> <td align=\"center\"><input type=\"radio\" name=\"id\" value=\"$id\"></td> <td align=\"center\">$name</td> <td align=\"center\"><img src=\"$photo\" /></td> Quote Link to comment https://forums.phpfreaks.com/topic/83344-solved-retrieving-data-from-mysql-table-using-php/#findComment-424012 Share on other sites More sharing options...
rinteractive Posted December 27, 2007 Author Share Posted December 27, 2007 Thanks wolfrat i have used your coding but the image is not displaying Quote Link to comment https://forums.phpfreaks.com/topic/83344-solved-retrieving-data-from-mysql-table-using-php/#findComment-424018 Share on other sites More sharing options...
shreej21 Posted December 27, 2007 Share Posted December 27, 2007 in <img> tag you have to specify the source path. like where your image is stored that path like if my image is in image folder with name snap.jpg then the tag will be... <img src="image/snap.jpg"> like this u must specify the src for img tag. Quote Link to comment https://forums.phpfreaks.com/topic/83344-solved-retrieving-data-from-mysql-table-using-php/#findComment-424063 Share on other sites More sharing options...
wolfrat Posted December 27, 2007 Share Posted December 27, 2007 Thanks wolfrat i have used your coding but the image is not displaying hmm, can you maybe view the page source of the generated html, and post here what it says in the image tag? And how are you storing the images in the sql, just the image name/location, or the actual image file? Quote Link to comment https://forums.phpfreaks.com/topic/83344-solved-retrieving-data-from-mysql-table-using-php/#findComment-424120 Share on other sites More sharing options...
revraz Posted December 27, 2007 Share Posted December 27, 2007 My first suggestion would be to read the Sticky posts here. They explain how to properly post your code so people will be more eager to help you. hey guys i am new to php , Quote Link to comment https://forums.phpfreaks.com/topic/83344-solved-retrieving-data-from-mysql-table-using-php/#findComment-424121 Share on other sites More sharing options...
rinteractive Posted December 28, 2007 Author Share Posted December 28, 2007 Thanks wolfrat my problem is solved. The image is displaying Thanks a lot, your code is very helpful Quote Link to comment https://forums.phpfreaks.com/topic/83344-solved-retrieving-data-from-mysql-table-using-php/#findComment-424547 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.