Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi ,

I have table in Mysql including with id and item, both of them are boolean(1,0) and I want show the Image in html page , If item equal to "1" show Image1 , If item equal to "0" show Image2. form the image folder. anybody can help me pls.thank you.
Posted
Updated 25-Nov-11 19:23pm
v2

1 solution

mysql_connect(host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT <fieldname> FROM <table>";
$result=mysql_query($query);
$image=mysql_result($result,0);
if($image == 1)
echo "<img src="path of image1" />";
if($image == 0)
echo "<img src="path of image2" />";
mysql_close();

It just a code snippet that may not be appropriate for you, but may lead the way to your solution.
 
Share this answer
 
v3
Comments
Mohammad Ali_7 26-Nov-11 3:56am    
Thank you for helping, with a little changing is working now ! thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900