Tutorials

Random fanlistings

A little code posted by Vix at our forums, which will show random fanlistings wherever you want.

Here’s what you have to do.

  1. Copy the following code and save it into a file named random.php

    <?php $linkcount = 10;
    require 'config.php';
    
    $result = mysql_query('SELECT * FROM ' . $table_link . ' ORDER BY RAND() LIMIT ' . $linkcount);
    if (mysql_num_row($result) < 1) echo 'There are no links in this category.';
    else {
    	while($row = mysql_fetch_assoc($result)) {
    		if ($row['width'] < 10) $insert_width = '';
    		else $insert_width = ' width="' . $width . '"';
    		if ($row['height'] < 10) $insert_height = '';
    		else $insert_height = ' height="' . $height . '"';
    		?>
    		<a href="<?php echo $row['url']; ?>"><img border="0" src="<?php echo $base_url; $row['image']; ?>" alt="<?php echo $row['name']; ?>"<?php echo $insert_width;$insert_height; ?>></a>
    		<?php
    	}
    }
    ?>
  2. Change the $linkcount to the number of buttons you want to display. By default it is set to 10. If you want another number, just change the first line of the code. For instance, if you only want five, use this:

    <?php $linkcount = 5;
  3. Upload random.php to the folder where flinx is located.

  4. Include it in your webpage. Use this:

    <?php include "/path/to/flinx/folder/random.php"; ?>

    (Remember to change the part in quotes to your absolute path or it won’t work).

Comments

Error Comments are closed for this entry.