Log in

View Full Version : PHP & Image Power Zoomer



funkfact
11-17-2010, 02:29 PM
Hi,

I have just viewed the Image Power Zoomer and love what it does, however the instructions say that you have to define a unique image name to apply it to. I am new to PHP and have been making an image uploader that places a link to the image in my database. Is it possible to modify the following code, or that of the Image Zoomer to work with images loaded in this way?


<?php
require('includes/dbinfo.php');
mysql_connect($host, $username, $password) or die(mysql_error()) ;
mysql_select_db($db_name) or die(mysql_error()) ;
$data = mysql_query("SELECT * FROM image_bank") or die(mysql_error());
?>
<?php
while($info = mysql_fetch_array( $data )) {
Echo "<img src=http:images_new/".$info['photo'] .">; }
?>

Any help greatly appreciated :-)

FF

Schmoopy
11-17-2010, 06:36 PM
Don't know exactly what you mean, but here's what I think you want:



<?php
require('includes/dbinfo.php');
mysql_connect($host, $username, $password) or die(mysql_error()) ;
mysql_select_db($db_name) or die(mysql_error()) ;
$data = mysql_query("SELECT * FROM image_bank") or die(mysql_error());

// Start the counter off at 1 (the first image)
$counter = 1;

while($info = mysql_fetch_array( $data )) {
echo "<img src=\"images_new/".$info['photo'] ."\" id=\"image_" . $counter . "\"/>";
// Increment the counter on each loop, for each new image
$counter++;
}

?>


This will output the images, with unique ids like so:

image_1
image_2

etc...

Let me know if you have any issues with this.