I have a link on my site that shows a random post, and the posts are stored in a separate array.
echo "<a href=\"https://www.mysite.com/post.php?id=".$random_post."\" target=\"_blank\">Random Post</a>";
I'm looking to develop the link to be automatically refreshing... By this I mean, each time I press refresh, the PHP Script retrieves a new random post ID, but as of now if I click the link again, I view the same post.
I have the link on top of my site, and the posts load in a separate iframe below... I wanted to enable a function that will grab a new random post ID for the link upon each click on it, similar to StumbleUpon...
Thanks in advance!
I think a method that would make more sense would be to have a randompost.php
, which the link goes to. It would pick a random post and send a Location (redirect) header, sending the user to a random post.
// Determine random post.
// Redirect
header("Location: https://www.mysite.com/post.php?id=$random_post");