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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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