Firstly, let me say that Drupal rocks! Awesome CMS and awesome community.
I have been searching this website for a PHP snippet that would do the following;
Pull a number (which could be set to let's say 10) of random links from the database and post them on a page node. I would like these links to be refreshed daily with a new set. I have been trying to do something like this and have set up my database (based on something I found on the net) by using this code;
CREATE TABLE `links` (
`id` int(11) NOT NULL auto_increment,
`link` text NOT NULL,
`text` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM;
No problem. I inserted values like so;
insert into links values ('NULL',"http://www.site1.com", "link description");
insert into links values ('NULL',"http://www.site2.com", "link description");
insert into links values ('NULL',"http://www.site3.com", "link description");
Then I tried altering PHP that I found like so;
$num_displayed = 3 ;
$result = mysql_query ("SELECT * FROM links ORDER BY RAND() LIMIT $num_displayed");
while ($row = mysql_fetch_array($result))
print "<a href=\"$row["link"]\">
<img src=\"$row["image"]\" border="0">$row["text"]\"/>
</a>" ;
I know, I know! I am no good with PHP, so it's probably terrible. It doesn'y have the code for changing the links set daily, but I'd thought that I'd start small and build up to that. If anyone can help me out I would be eternally grateful.