Hello to everyone.
Can someone give me a little help, i am new in PHP and i got stock in some php code.
I am trying to create a website which have some php code to call some data from mysql database
i have found some part of the php code in some other forum the code works perfect the only problem i have is that when i want to call the row of images i just gate the name of the image not the image as view " image.jpg"
the code i have is like below.
<?php
// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("sherbime") or die(mysql_error());
$data = mysql_query("SELECT * FROM products")
or die(mysql_error());
Print "<table border=1 cellpadding=3>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
echo "<th></th> <td>".$row['Image'] . "</td>";
Print "<th> Desktop:</th> <td>".$info['Desktop'] . "</td> ";
Print "<th>Model:</th> <td>".$info['Model'] . "</td> ";
Print "<th>Parameters:</th> <td>".$info['Parameters'] . "</td> ";
Print "<th>Price:</th> <td>".$info['Price'] . " </td></tr>";
}
Print "</table>";
?>
i am using wampserver, also have another question, where should i store my images to call from database??
thanks in advance Enzo
Hot to call an image from mysql database
Moderators: egami, macek, gesf
hi,
use image tag for display image on a web page.
in the given script the change which i have done it should be in bold letters.
<?php
// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("sherbime") or die(mysql_error());
$data = mysql_query("SELECT * FROM products")
or die(mysql_error());
Print "<table border=1 cellpadding=3>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
echo "<th>Image</th> <td><img src=".$row['Image'] . " height='100' width='100' /></td>";
Print "<th> Desktop:</th> <td>".$info['Desktop'] . "</td> ";
Print "<th>Model:</th> <td>".$info['Model'] . "</td> ";
Print "<th>Parameters:</th> <td>".$info['Parameters'] . "</td> ";
Print "<th>Price:</th> <td>".$info['Price'] . " </td></tr>";
}
Print "</table>";
?>
The answer to your question is that, to fetch from database, images are just only for display, and if you want to save, then you can make a link on each image so that it should open in another page (where you can put the code of saving images using move_uploaded_file function).
use image tag for display image on a web page.
in the given script the change which i have done it should be in bold letters.
<?php
// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("sherbime") or die(mysql_error());
$data = mysql_query("SELECT * FROM products")
or die(mysql_error());
Print "<table border=1 cellpadding=3>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
echo "<th>Image</th> <td><img src=".$row['Image'] . " height='100' width='100' /></td>";
Print "<th> Desktop:</th> <td>".$info['Desktop'] . "</td> ";
Print "<th>Model:</th> <td>".$info['Model'] . "</td> ";
Print "<th>Parameters:</th> <td>".$info['Parameters'] . "</td> ";
Print "<th>Price:</th> <td>".$info['Price'] . " </td></tr>";
}
Print "</table>";
?>
The answer to your question is that, to fetch from database, images are just only for display, and if you want to save, then you can make a link on each image so that it should open in another page (where you can put the code of saving images using move_uploaded_file function).
hi,
To display embed image in a pop window,
use jquery and if you are using hyperlink <a href=""> then it is just only display the original image in new tab or new window, so i suggest to you to use jquery there for display image in pop up window
To display embed image in a pop window,
use jquery and if you are using hyperlink <a href=""> then it is just only display the original image in new tab or new window, so i suggest to you to use jquery there for display image in pop up window