/    Sign up×
Community /Pin to ProfileBookmark

A random text displayer

Does anyone know of a php/sql script that exists where you can enter a bunch of row values into a table, and have the php script randomly chose one of them to display. The only catch is, preferably in an admin section or something, the row values have to have check box or something, so only those particular values you want a random selection from has to be checked. Does anything like this exist? I need to find something like it urgently. Thanks in advance!

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@GarySMay 02.2006 — Not exactly sure that I'm hitting the mark, but I'll take a couple of shots.

You could get a random record from a database table with something like:

$count = select count(*) from tablename;

$offset = rand(0,$count);

select *
from table limit $offset,1

You also mentioned checkboxes - the ability to mark some of the entries as "selected". The above (psuedo) code could be tweaked accordingly:

$count = select count(*) from tablename where checked=1;

$offset = rand(0,$count);

select *
from table where checked=1 limit $offset,1


Is this anywhere near what you're looking for?
Copy linkTweet thisAlerts:
@ToonauthorMay 02.2006 — Yes, something like that. Unfortunately, I dont have any php coding skills yet, so Im looking for something already made, so all I have to do is install the sql table, and use the php pages to enter the values I want in the db, and use check boxes to chose which of those values I want to have included in the random chosing. Id even be willing to pay a small fee for a script like that
Copy linkTweet thisAlerts:
@WebnerdMay 02.2006 — What is your MysQL table going to look like? What fields do you need?
Copy linkTweet thisAlerts:
@ToonauthorMay 02.2006 — wel, it would at least need a a text field for the data that will be in used in the random display. a field to represent the check box, and maybe a unique ID field. I dont know what else it might need, since it seems to be a simple database
Copy linkTweet thisAlerts:
@WebnerdMay 02.2006 — Is it MySQL, do you have access to use MySQL and create databases? Do you have access to create tables? So much more information needed...
×

Success!

Help @Toon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...