•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,534 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,027 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 3322 | Replies: 11
![]() |
<?php
$conn = mysql_connect("localhost", "root", "general");
mysql_select_db("cms");
$result = mysql_query("SELECT * FROM Category");
echo "<table width='400' border='1' cellpadding ='3' cellspacing ='4' bordercolor='#45310F' fontcolor=#FFFFFF>";
//$cimage =
while($take = mysql_fetch_array($result))
{
echo"<tr><tr>";
echo "<tr><td>";
print $take['cat_name']."<br>";
echo "</td><td>";
print $take['cat_desc']."<br>";
echo "</td></td>";
echo "<t6><td>";
echo $take['cat_image']."<br>";
echo "</td></tr></tr>";
echo "<tr><tr>";
}
echo "</font>";
echo "</table>";
echo "<br><br><br>";
mysql_close($conn);
?>
this is my code to get the images from the database...
i have uploaded the images...
but..when i tried to view it only the image name appears..the image doesnt appear...
The image name in the mysql is called cat_image
$conn = mysql_connect("localhost", "root", "general");
mysql_select_db("cms");
$result = mysql_query("SELECT * FROM Category");
echo "<table width='400' border='1' cellpadding ='3' cellspacing ='4' bordercolor='#45310F' fontcolor=#FFFFFF>";
//$cimage =
while($take = mysql_fetch_array($result))
{
echo"<tr><tr>";
echo "<tr><td>";
print $take['cat_name']."<br>";
echo "</td><td>";
print $take['cat_desc']."<br>";
echo "</td></td>";
echo "<t6><td>";
echo $take['cat_image']."<br>";
echo "</td></tr></tr>";
echo "<tr><tr>";
}
echo "</font>";
echo "</table>";
echo "<br><br><br>";
mysql_close($conn);
?>
this is my code to get the images from the database...
i have uploaded the images...
but..when i tried to view it only the image name appears..the image doesnt appear...
The image name in the mysql is called cat_image
My suggestion is to put the path to the image in the database. eg http://www.[name].com/images/cat_image.jpg
and then echo it inside an image tag.
and then echo it inside an image tag.
Last edited by Venom Rush : Oct 15th, 2007 at 12:36 pm.
•
•
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation:
Rep Power: 3
Solved Threads: 68
echo <img src=$take['cat_image']>.
put it inside the image...
put it inside the image...
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
http://ryantetek.wordpress.com
•
•
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation:
Rep Power: 3
Solved Threads: 68
echo "<img src='.$take['cat_image'].'>";
put necessary quotes to display image.
put necessary quotes to display image.
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
http://ryantetek.wordpress.com
•
•
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation:
Rep Power: 3
Solved Threads: 68
oops!I also made the wrong concatenation. try this one if the latter produces the same error.
echo "<img src=' ".$take['cat_image']." '>";
echo "<img src=' ".$take['cat_image']." '>";
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
http://ryantetek.wordpress.com
•
•
•
•
The way I was thinking was to upload the image to the ftp and then INSERT the path to where the image is inside the database.
Then essentially you'd retrieve the path of the image from the database and insert it inside an img tag.
Hi....
venom rush....
Thanks for the suggestion...i will try that also...
But the echo one works...
i can see only the image tag...that is the box, but not the image....
when i upload the image...i upload into a folder ..
and also to mysql..
<?php
$query = "INSERT INTO category(cat_name, cat_desc, cat_image)" .
"VALUES('$cname', '$cdesc','$cimage')";
mysql_query($query,$link)
or die("Couldn't add data to add to \"Category\" table:
".mysql_error($link));
mysql_close($link);
?>
This is how I insert into mysql..
but still i cudnt able to see the image...
Did i made any wrong...?
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation:
Rep Power: 3
Solved Threads: 72
i have a problem with images on my server where the extension will change to uppercase when uploaded. some servers will not display the image if the extension in the database and the one in the folder are not the same.
also did you add the folder to the path. (/folder/image.jpg)
also did you add the folder to the path. (/folder/image.jpg)
Last edited by kkeith29 : Oct 16th, 2007 at 11:51 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- require urgent help to retrieve image from database (PHP)
- storing images into database (ASP.NET)
- Displaying Images( buffered data ) from the Database using Java (Java)
- retrieving images from database in thumbnail form (PHP)
- how to convert images to binary to store in database (Java)
- uploading Images into Database (ASP.NET)
- PHP Members HELP W/DB Images (PHP)
- Retrieve Information from Database & Display into ASP.NET Web Controls Textbox (ASP.NET)
- Saving Images In Database (VB.NET)
Other Threads in the PHP Forum
- Previous Thread: shell_exec problem
- Next Thread: Display URL from another traget (php)


Linear Mode