Hi,
I am quite new to PHP, so my question might be quite an easy one...
What I would like to do is to select and publish a daily random selection of 20 approved links in a MySQL db. I would also like to avoid any repetitive urls in the output. So far, I have been able to make a selection of 20 random approved links.
So, the parts I am missing are: the DAILY updates (and not every the page opens) and the REPETITIVE links that show up...
This is what I have put together:
$dbLink = mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName"); $sqlquery = "SELECT * FROM $table WHERE approved = '1' AND category = 'category_name' ORDER BY RAND() limit 20";
$result = mysql_query($sqlquery);
$number = mysql_numrows($result);
$i = 0;
if ($number < 1) {
print "<CENTER><P>There Were No Results for Your Search</CENTER>";
}
else {
while ($number > $i) {
$thepix = mysql_result($result,$i,"pics");
$theurl = mysql_result($result,$i,"url");
$thedescr = mysql_result($result,$i,"description");
print "$thepix pics - <a href=$theurl target=_blank>$thedescr</a><br>";
$i++;
}
}
mysql_close($dbLink);
Can anyone help me out? Thanks in advance!