Jump to content

dynamic thumbnail


nortksi

Recommended Posts

Hi all, completely new at this and have got myself stuck!

 

I am trying to display a thumbnail image by connecting to my database and retrieving the URL that points to the image.

 

I know that the connection is working but I can't seem to get it to point to the image. Probably something really simple. Here's my code:

 

<!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>Image Swap Using CSS</title>
<style type="text/css">

body {
margin: 0;
padding: 0;
background-color:#000000;
}

img {
margin: 0;
padding: 0;
border: none;
}

.test {
margin: 0;
padding: 0;
width: 99px;
height: 130px;
}

.test a:hover img {
visibility:hidden;
}

</style>
</head>

<body>
<?php
	// connect to the database
	mysql_connect("********", "****") or die(mysql_error()); 
	mysql_select_db("eliteescorting") or die(mysql_error());
	$start=0;

	// expand on the searches
	$data=mysql_query("SELECT * FROM escorts WHERE base = 'manchester' ORDER BY RAND()");
	$num_results=@mysql_num_rows($data);

	for($ii = $start;$ii < $num_results; $ii++){
?>
<div class="test"><a href="#"><img src="<?php echo $data[$ii]['thumb'];?>" /></a></div>
<?php } ?>
</body>

</html>

 

In my mySQL field 'thumb' contains the full URL of the image ie http://www............

 

This is just for testing, I'll get round to sorting out security issues later.

 

Your help will be greatly appreciated!

 

Regards,

Nortski.

Link to comment
https://forums.phpfreaks.com/topic/210582-dynamic-thumbnail/
Share on other sites

mysql_query only returns a result resource. In order to retrieve the results from the query, you'll need to use one the mysql_fetch_*() functions, for example mysql_fetch_assoc.

 

Example php code

$query = 'SELECT thumb FROM escorts WHERE base = 'manchester' ORDER BY RAND()';
$result = mysql_query($query);

while($row = mysql_fetch_assoc($result))
{
    echo $row['thumb'] . '<br />';
}

Link to comment
https://forums.phpfreaks.com/topic/210582-dynamic-thumbnail/#findComment-1098628
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.