Jump to content

Recommended Posts

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

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>

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.

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?

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.