Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [MOD] Showing thumbs in link lists  (Read 4608 times)

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • “I'm a self-made man and worships my creator.”
    • p-ahlqvist.com
[MOD] Showing thumbs in link lists
« on: June 30, 2006, 12:41:13 pm »

Hehe, I've dabbled some with the script meant to show images when hovering a download link. I wanted to show a clickpic (will be bigger images when I get time to make them) as a teaser for the affiliates on my site. Now the textlinks are better SEO wise I'm told, but I still wanted the images to show, so I thought some, hehe... yes I did. And come to think of the downloadscript thingy Ave-man provided me with. So... Ok, if you wanna know what I mean, check out the Affiliates a bit down to the left: http://p-ahlqvist.com

Now that did'nt work at all first as I just copied it and thought it would just show the thumbs for the links, DUH. So Instead after a cupla minutes of thinking I did this:

First I copied the download.php, renamed it to redirect.php and edited it to fit my needs. It looks like this now:

Code: [Select]
$file = $_GET['file'];
/* specify path containing files */
$download_path = '/redirect/';

/* set up mysql connection */
include("inc.mysql.php");

if (!empty($file)) {
  /* query database */
  $result = mysql_query('SELECT filename FROM redirect');

  /* check each row for filename and send file via http header */
  while ($row = mysql_fetch_assoc($result)) {
    if ($row["filename"] == $file) {
      $result = mysql_query("UPDATE redirect SET redirect=redirects+1 WHERE filename='" . $file . "'");
      header('Location: ' . $redirect_path . basename($file));
    }
  }
}
?>
Then you gotta have this, I think ;) namely the inc.mysql.php:
Code: [Select]
/* mysql data */
$db_host = "localhost";
$db_user = "username";
$db_pass = "password";
$db_name = "name of database";

/* connect to mysql */
$link = @mysql_connect($db_host, $db_user, $db_pass);

/* select database */
mysql_select_db($db_name, $link);
?>
Both these placed at the root.

Ok, now the base of it all is there. Now all you gotta do is create the db table. I have this settings:
Quote
ID int and primary - What number in descending order the link has
title CHAR(100) - The linktext itself
filename CHAR(100) - The link: http://url.com
thumb CHAR(100) - The path to the thumb, ie images/image.jpg
DONE ! Still one thing remaining though. You've gotta place the code that shows what you want at the site. Where is up to you, but it looks like this:
Code: [Select]
$query = "SELECT * FROM redirect ORDER BY redirects DESC LIMIT 8";
$result = mysql_query($query);
while ($r = mysql_fetch_array($result)) {
echo "".$r['title']." \"\"        
";
}
?>
Just thought I'd do something for this forum even if prollu anyone could have done it themelf, hehe...

Patric.


EDIT --> Oh, oh I almost forgot, hehe... that will not work as you think unless the CSS is made out in a special way, and heres how to do that:
Quote
/*---------- 'Redirects' image styles -----------*/

.redirect img{
border: 1px solid white;
margin: 0 5px 5px 0;
}
.redirect:hover{
background-color: transparent;
}
.redirect:hover img{
border: 1px solid #aba;
}
.redirect span{ /*CSS for enlarged image*/
position: absolute;
background-color: #aba;
padding: 3px 3px 2px 3px;
left: -1000px;
border: 1px solid #767676;
visibility: hidden;
color: black;
text-decoration: none;
text-align:center;
}
.redirect span img{ /*CSS for enlarged image*/
border-width: 0;
padding: 2px;
}
.redirect:hover span{ /*CSS for enlarged image*/
visibility: visible;
top: 736px;/*position where enlarged image should offset vertically*/
left: 360px; /*position where enlarged image should offset horizontally */
z-index: 50;
}
Logged
"It's only dead fish that goes with the flow... "
Updated

brauck

  • Hero Member
  • *****
  • Karma: 18
  • Posts: 556
    • http://www.hbw-webdesign.nl/
[MOD] Showing thumbs in link lists
« Reply #1 on: June 30, 2006, 12:54:03 pm »

Isn't that nice. You get better and better; one day you beat us all :)
Logged
Confidence is reduced complexity.
brauck.nl for free css templates

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • “I'm a self-made man and worships my creator.”
    • p-ahlqvist.com
[MOD] Showing thumbs in link lists
« Reply #2 on: June 30, 2006, 12:56:59 pm »

*making faces and grins - impersonating John Wayne*

 - "He, that'll be the day, mister... Is that a dagger I see before me ??"
Logged
"It's only dead fish that goes with the flow... "
Updated

David

  • Hero Member
  • *****
  • Karma: 7
  • Posts: 567
[MOD] Showing thumbs in link lists
« Reply #3 on: June 30, 2006, 01:01:14 pm »

Thanks Patric for this Affiliate section on your homepage ;) ...and thanks for all your work!
Logged

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • “I'm a self-made man and worships my creator.”
    • p-ahlqvist.com
[MOD] Showing thumbs in link lists
« Reply #4 on: June 30, 2006, 01:10:21 pm »

Hehe, right back at ya, mate :)
Logged
"It's only dead fish that goes with the flow... "
Updated

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
[MOD] Showing thumbs in link lists
« Reply #5 on: June 30, 2006, 06:25:33 pm »

Hey Patric - a dandy little script indeed! :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

albert

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 405
    • http://www.oswt.co.uk/
[MOD] Showing thumbs in link lists
« Reply #6 on: July 01, 2006, 05:11:20 am »

Hi Patric

this is a great code, will have to use this on my site:)

Its nice to see more site designs for sNews here too as well.

I have nearly done testing oswt now so will add all the designs for sNews
too it as well.

Albert
 

Quote from: Patric
Hehe, I've dabbled some with the script meant to show images when hovering a download link. I wanted to show a clickpic (will be bigger images when I get time to make them) as a teaser for the affiliates on my site. Now the textlinks are better SEO wise I'm told, but I still wanted the images to show, so I thought some, hehe... yes I did. And come to think of the downloadscript thingy Ave-man provided me with. So... Ok, if you wanna know what I mean, check out the Affiliates a bit down to the left: http://p-ahlqvist.com

Now that did'nt work at all first as I just copied it and thought it would just show the thumbs for the links, DUH. So Instead after a cupla minutes of thinking I did this:

First I copied the download.php, renamed it to redirect.php and edited it to fit my needs. It looks like this now:

Code: [Select]
$file = $_GET['file'];
/* specify path containing files */
$download_path = '/redirect/';

/* set up mysql connection */
include("inc.mysql.php");

if (!empty($file)) {
  /* query database */
  $result = mysql_query('SELECT filename FROM redirect');

  /* check each row for filename and send file via http header */
  while ($row = mysql_fetch_assoc($result)) {
    if ($row["filename"] == $file) {
      $result = mysql_query("UPDATE redirect SET redirect=redirects+1 WHERE filename='" . $file . "'");
      header('Location: ' . $redirect_path . basename($file));
    }
  }
}
?>
Then you gotta have this, I think ;) namely the inc.mysql.php:
Code: [Select]
/* mysql data */
$db_host = "localhost";
$db_user = "username";
$db_pass = "password";
$db_name = "name of database";

/* connect to mysql */
$link = @mysql_connect($db_host, $db_user, $db_pass);

/* select database */
mysql_select_db($db_name, $link);
?>
Both these placed at the root.

Ok, now the base of it all is there. Now all you gotta do is create the db table. I have this settings:
Quote
ID int and primary - What number in descending order the link has
title CHAR(100) - The linktext itself
filename CHAR(100) - The link: http://url.com
thumb CHAR(100) - The path to the thumb, ie images/image.jpg
DONE ! Still one thing remaining though. You've gotta place the code that shows what you want at the site. Where is up to you, but it looks like this:
Code: [Select]
$query = "SELECT * FROM redirect ORDER BY redirects DESC LIMIT 8";
$result = mysql_query($query);
while ($r = mysql_fetch_array($result)) {
echo "".$r['title']." \"\"        
";
}
?>
Just thought I'd do something for this forum even if prollu anyone could have done it themelf, hehe...

Patric.


EDIT --> Oh, oh I almost forgot, hehe... that will not work as you think unless the CSS is made out in a special way, and heres how to do that:
Quote
/*---------- 'Redirects' image styles -----------*/

.redirect img{
border: 1px solid white;
margin: 0 5px 5px 0;
}
.redirect:hover{
background-color: transparent;
}
.redirect:hover img{
border: 1px solid #aba;
}
.redirect span{ /*CSS for enlarged image*/
position: absolute;
background-color: #aba;
padding: 3px 3px 2px 3px;
left: -1000px;
border: 1px solid #767676;
visibility: hidden;
color: black;
text-decoration: none;
text-align:center;
}
.redirect span img{ /*CSS for enlarged image*/
border-width: 0;
padding: 2px;
}
.redirect:hover span{ /*CSS for enlarged image*/
visibility: visible;
top: 736px;/*position where enlarged image should offset vertically*/
left: 360px; /*position where enlarged image should offset horizontally */
z-index: 50;
}
Logged
Albert
http://snews.awddesign.co.uk/snews/ site: v1.3
http://snews.awddesign.co.uk/           site: v1.2 http://www.awddesign.co.uk/
“Putting together the largest collection of sNews 1.5 designs. Coming very soon :)

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • “I'm a self-made man and worships my creator.”
    • p-ahlqvist.com
[MOD] Showing thumbs in link lists
« Reply #7 on: July 02, 2006, 10:36:28 am »

Quote
...this is a great code, will have to use this on my site:)
...
Wow, Li'l old me have made something that Abe-man, the guru, will use. That is great. :)

EDIT--> And credit goes where credit is due - Avenir made this original code. I just thought some and made appropriate changes, and they weren't massive ;)...
Logged
"It's only dead fish that goes with the flow... "
Updated

albert

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 405
    • http://www.oswt.co.uk/
[MOD] Showing thumbs in link lists
« Reply #8 on: July 02, 2006, 11:50:08 am »

Hi Patric

did not use the code above, I had to make my own, only when I came to see if 1.5 was out.
I saw your site with the rollovers.. Very Cool too as well.

My code will still needs to be updated later as will need to add a hit counter to it.

will add the loging part to http://www.oswt.co.uk later so you can add your designs :)

Albert
Logged
Albert
http://snews.awddesign.co.uk/snews/ site: v1.3
http://snews.awddesign.co.uk/           site: v1.2 http://www.awddesign.co.uk/
“Putting together the largest collection of sNews 1.5 designs. Coming very soon :)

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • “I'm a self-made man and worships my creator.”
    • p-ahlqvist.com
[MOD] Showing thumbs in link lists
« Reply #9 on: July 02, 2006, 12:21:34 pm »

Great, Abe-man. Will do. Just to swoosh them up as zippies ??
Logged
"It's only dead fish that goes with the flow... "
Updated