Free Press Release Submission




MB Publishing Webmaster Resource ::
 Forum FAQForum FAQ   SearchSearch   UsergroupsUsergroups   ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin 


Randomise block-Top10_Downloads.php

 
Post new topic   Reply to topic    MB Publishing Webmaster Resource Forum Index -> Nuke Blocks
View previous topic :: View next topic  
Author Message
Colocation
Site Admin
Site Admin


Joined: Jan 07, 2004
Posts: 412

PostPosted: Tue Sep 21, 2004 9:29 am    Post subject: Randomise block-Top10_Downloads.php Reply with quote

How can we randomise the following block-Top10_Downloads.php block:

Code:
if (eregi("block-Top10_Downloads.php",$_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
    die();
}

global $prefix, $db;

$a = 1;
$sql = "SELECT lid, title FROM ".$prefix."_downloads_downloads ORDER BY hits DESC LIMIT 0,10";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
   $title2 = ereg_replace ("_", " ", $row[title]);
    $transfertitle = str_replace(" ", "_", $row[title]);
    $content .= "<strong><big>·;</big></strong> ;;$a: <a href=\"downloadview-details-$row[lid]-$transfertitle.html\">$title2</a><br>";
    $a++;
}
Back to top
View users profile Send private message Visit posters website Yahoo Messenger
Humpa
Site Admin
Site Admin


Joined: Feb 05, 2004
Posts: 23

PostPosted: Wed Sep 22, 2004 2:34 pm    Post subject: Reply with quote

Try this: icon_smile.gif
Code:
if (eregi("block-Top10_Downloads.php",$_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
    die();
}

global $prefix, $db;

$a = 1;
$sql = "SELECT lid, title FROM ".$prefix."_downloads_downloads ORDER BY RAND() LIMIT 0,10";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
   $title2 = ereg_replace ("_", " ", $row[title]);
    $transfertitle = str_replace(" ", "_", $row[title]);
    $content .= "<strong><big>·;</big></strong> ;;$a: <a href=\"downloadview-details-$row[lid]-$transfertitle.html\">$title2</a><br>";
    $a++;
}
Back to top
View users profile Send private message Visit posters website
Colocation
Site Admin
Site Admin


Joined: Jan 07, 2004
Posts: 412

PostPosted: Wed Sep 22, 2004 2:47 pm    Post subject: Charming Reply with quote

Works like a charm, thanks!

I took out the highlighted bits, cause they looked ugly.

Quote:
if (eregi("block-Top10_Downloads.php",$_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}

global $prefix, $db;

$a = 1;
$sql = "SELECT lid, title FROM ".$prefix."_downloads_downloads ORDER BY RAND() LIMIT 0,10";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$title2 = ereg_replace ("_", " ", $row[title]);
$transfertitle = str_replace(" ", "_", $row[title]);
$content .= "<strong><big>·;</big></strong> ;;$a: <a href=\"downloadview-details-$row[lid]-$transfertitle.html\">$title2</a><br>";
$a++;
}
Back to top
View users profile Send private message Visit posters website Yahoo Messenger
Humpa
Site Admin
Site Admin


Joined: Feb 05, 2004
Posts: 23

PostPosted: Wed Sep 22, 2004 4:04 pm    Post subject: Reply with quote

... you're welcome : )
I had actually never used the Rand() in a mysql_query before - not sure why, since that is a handy way to get a random result. icon_wink.gif
Back to top
View users profile Send private message Visit posters website
Display posts from previous:   
Post new topic   Reply to topic    MB Publishing Webmaster Resource Forum Index -> Nuke Blocks All times are GMT + 1 Hour
Page 1 of 1

 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Home | News Feeds | Release Archive | Web Marketing | Weight Loss | Publish Your Links | Press Release Topics | Free Downloads | Press FAQs | AvantGO | Amazon Store
Webmaster Forums | Search Releases | Press Topics | Feedback | Submit Press Release | Webmaster Surveys | Recommend | Top | Account | PM | Prweb | Free Link Submission | Add Downloads | New Media | Audio School | TOS

The comments are property of their posters, all the rest 2004 - 2008 by MB
Audana Ltd
You can syndicate our news using the file backend.php
Web site engine's code is Copyright © 2003 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 1.242 Seconds. -