GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Looking for a script... (https://gfy.com/showthread.php?t=807970)

F U S I O N 02-15-2008 05:43 PM

Looking for a script...
 
I have a list of 100 urls and descriptions that look like this:

SiteName.com - This is a description of the above site...

I want to have a page load and have 20-30 of these links be displayed at a time. Refresh the page and have a different set of 30 links load, all random.

Any ideas of a script or snippet of code I could use to accomplish this? I searched google but can't seem to find a script that will display the amount of links that I want it to...

Thanks in advance :)

Swish 02-15-2008 07:00 PM

Something like this:

Code:

<?php

$ARRAY = array(
    'sitename1.com' => 'This is a description',
    'sitename2.com' => 'This is a description'
    );

foreach ( $ARRAY as $URL => $DESC )
    print "<a href=\"$URL\">$URL</a> - $DESC\n";

?>


da man 02-15-2008 07:02 PM

I love your sig Swish

F U S I O N 02-16-2008 02:17 AM

Thanks Swish!

How do I go about only displaying a certain amount of links at a time tho out of a bigger list?

k0nr4d 02-16-2008 02:34 AM

Code:

<?php

$ARRAY = array(
    'sitename1.com' => 'This is a description',
    'sitename2.com' => 'This is a description'
    );

shuffle($ARRAY);
$counter=0;
foreach ( $ARRAY as $URL => $DESC ) {
    if($counter < 30) {
    print "<a href=\"$URL\">$URL</a> - $DESC\n";
    $counter++;
    }
}
?>

A bit half-assed. I would do this with a mysql db instead.

Emil 02-16-2008 04:45 AM

Quote:

Originally Posted by k0nr4d (Post 13790623)
A bit half-assed. I would do this with a mysql db instead.

Sounds pretty unnecessary for such a small script.

F U S I O N 02-16-2008 02:48 PM

Thanks, Ill give that a shot

Swish 02-18-2008 03:58 PM

Quote:

Originally Posted by k0nr4d (Post 13790623)
Code:

<?php

$ARRAY = array(
    'sitename1.com' => 'This is a description',
    'sitename2.com' => 'This is a description'
    );

shuffle($ARRAY);
$counter=0;
foreach ( $ARRAY as $URL => $DESC ) {
    if($counter < 30) {
    print "<a href=\"$URL\">$URL</a> - $DESC\n";
    $counter++;
    }
}
?>

A bit half-assed. I would do this with a mysql db instead.

There are obviously more elegant ways to do this. This was only a simple example.

Swish 02-18-2008 03:59 PM

Quote:

Originally Posted by da man (Post 13789131)
I love your sig Swish

LOL Thanks :thumbsup


All times are GMT -7. The time now is 01:21 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123