textbox Posted May 22, 2007 Share Posted May 22, 2007 Hello, id like to pull out a feature profile on one of my pages, and allow it in the feature spot for 24 hours. All i need pullling out is the users picture, headline, location and name which i am fine with. I have no idea where to start on the feature part. Any help would be great. Nick Quote Link to comment https://forums.phpfreaks.com/topic/52475-pulling-out-a-feature-profile/ Share on other sites More sharing options...
trq Posted May 22, 2007 Share Posted May 22, 2007 Probably the easiest way would be to have a cronjob run every 24 hours pointing to a script which pulls a random profile id from your database and places it with a featured profile table. Or is there some way you wish to choose these featured profiles ? Quote Link to comment https://forums.phpfreaks.com/topic/52475-pulling-out-a-feature-profile/#findComment-258916 Share on other sites More sharing options...
textbox Posted May 22, 2007 Author Share Posted May 22, 2007 Nope, can be totally automated and random. Is a cron job the best way to do this? Are they hard to do?! Thanks Thorpe! Quote Link to comment https://forums.phpfreaks.com/topic/52475-pulling-out-a-feature-profile/#findComment-258918 Share on other sites More sharing options...
trq Posted May 22, 2007 Share Posted May 22, 2007 Are they hard to do?! Shouldn't be too hard, but Ive never used a server that I didn't have shell access too. Set up the script first, then take a look at your hosts instructions for setting up cron. Most users do it through cPanel or something. Quote Link to comment https://forums.phpfreaks.com/topic/52475-pulling-out-a-feature-profile/#findComment-258920 Share on other sites More sharing options...
textbox Posted May 22, 2007 Author Share Posted May 22, 2007 Yeah i have a cron job tab on my cPanel. Should the script be something like SELECt * FROM users ORDER RAND LIMIT 1 query to pull out info Quote Link to comment https://forums.phpfreaks.com/topic/52475-pulling-out-a-feature-profile/#findComment-258923 Share on other sites More sharing options...
trq Posted May 22, 2007 Share Posted May 22, 2007 If you place another field in your existing users database (small int) you could simply use something like (not tested).... <?php // connect to db. // remove current featured profile. $result = mysql_query("UPDATE users SET featured = 0 WHERE featured = 1;"); // create new featured profile. $result = mysql_query("UPDATE users SET featured = 1 WHERE id = (SELECT RAND(id) FROM users LIMIT 1);"); ?> run through cron. Then... on you page to display the featured profile you'd just need.... SELECT * FROM users WHERE featured = 1; Quote Link to comment https://forums.phpfreaks.com/topic/52475-pulling-out-a-feature-profile/#findComment-258929 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.