I have written some horribly inefficient PHP, at the limit of my abilities, to select a random ID number from one of my tables, with the purpose of creating a URL which, when clicked, will take you to a random record in the table. I have it working in a test page, here - http://ada.abernyte.org/random.php
The code, for those interested, is;
Code: Select all
//connect to DB up here - not shown
$result = mysql_query("SELECT id FROM ContentItem ORDER BY RAND() LIMIT 1") or die(mysql_error());
if(is_resource($result) and mysql_num_rows($result)>0){
$row = mysql_fetch_array($result);
// echo $row["id"];
}
Code: Select all
<p><?php echo "<a href='http://ada.abernyte.org/ContentItem_view.php?SelectedID=".$row['id']."'>Display a Random Content Item Record</a>" ?></p>
But I am having trouble inserting my $row['id'] code into the array which builds the homelinks;
I've tried many different combinations - I'm sure it's a syntax issue, but my php skills are poor and I'm not sure what I'm doing wrong. It most often just displays a white page when I try to add it.
Any ideas would be much appreciated!
Ally