How to use a ranbom generator ...advanced style???

How to use a ranbom generator ...advanced style???

am 18.10.2007 15:40:26 von James54321

Hi, I did quite a bad subject heading so I'll try to explain it better
here.

I have a website (it is indeed really bad right now, I know that, so
please don't remind me). For a very long time now I have wanted it to
display a random slogan of my site from all of the possible slogans
that are stored in my MySQL database. I have recently found out how
to count the rows of a MySQL table and so I have made a script that
will select an appropriate row (according to the list of rows 1-12 for
example). BUT the problem I am having is that if i have a row that
I've deleted then that row can still be selected, as I have no way
(that I know) as to reference which rows are not deleted ..to be able
to ONLY show the slogans and not just an empty row of nothingness.

Is this possible, and if so, how?

P.S.
You can see the page which outputs the relevant random number here:
http://flavouredcandy.com/page.php?id=2 (its just under the right
banner).

Thanks, James.

Re: How to use a ranbom generator ...advanced style???

am 18.10.2007 15:49:07 von luiheidsgoeroe

On Thu, 18 Oct 2007 15:40:26 +0200, James54321 > =

wrote:

> Hi, I did quite a bad subject heading so I'll try to explain it better=

> here.
>
> I have a website (it is indeed really bad right now, I know that, so
> please don't remind me). For a very long time now I have wanted it to=

> display a random slogan of my site from all of the possible slogans
> that are stored in my MySQL database. I have recently found out how
> to count the rows of a MySQL table and so I have made a script that
> will select an appropriate row (according to the list of rows 1-12 for=

> example). BUT the problem I am having is that if i have a row that
> I've deleted then that row can still be selected, as I have no way
> (that I know) as to reference which rows are not deleted ..to be able
> to ONLY show the slogans and not just an empty row of nothingness.
>
> Is this possible, and if so, how?
>
> P.S.
> You can see the page which outputs the relevant random number here:
> http://flavouredcandy.com/page.php?id=3D2 (its just under the right
> banner).

Use RAND() in MySQL to select a random slogan from the database.

$chosen_slogan =3D mysql_query('SELECT slogan_id FROM slogans ORDER BY =

RAND() LIMIT 1');

-- =

Rik Wasmus

Re: How to use a ranbom generator ...advanced style???

am 21.10.2007 13:03:28 von James54321

On Oct 18, 2:49 pm, "Rik Wasmus" wrote:
> On Thu, 18 Oct 2007 15:40:26 +0200, James54321
> wrote:
>
>
>
> > Hi, I did quite a bad subject heading so I'll try to explain it better
> > here.
>
> > I have a website (it is indeed really bad right now, I know that, so
> > please don't remind me). For a very long time now I have wanted it to
> > display a random slogan of my site from all of the possible slogans
> > that are stored in my MySQL database. I have recently found out how
> > to count the rows of a MySQL table and so I have made a script that
> > will select an appropriate row (according to the list of rows 1-12 for
> > example). BUT the problem I am having is that if i have a row that
> > I've deleted then that row can still be selected, as I have no way
> > (that I know) as to reference which rows are not deleted ..to be able
> > to ONLY show the slogans and not just an empty row of nothingness.
>
> > Is this possible, and if so, how?
>
> > P.S.
> > You can see the page which outputs the relevant random number here:
> >http://flavouredcandy.com/page.php?id=2(its just under the right
> > banner).
>
> Use RAND() in MySQL to select a random slogan from the database.
>
> $chosen_slogan = mysql_query('SELECT slogan_id FROM slogans ORDER BY
> RAND() LIMIT 1');
>
> --
> Rik Wasmus

I'll try that now, and if it works thats really really clever, thank
you.

James.

Re: How to use a ranbom generator ...advanced style???

am 21.10.2007 14:16:51 von James54321

On Oct 21, 12:03 pm, James54321 wrote:
> On Oct 18, 2:49 pm, "Rik Wasmus" wrote:
>
>
>
> > On Thu, 18 Oct 2007 15:40:26 +0200, James54321
> > wrote:
>
> > > Hi, I did quite a bad subject heading so I'll try to explain it better
> > > here.
>
> > > I have a website (it is indeed really bad right now, I know that, so
> > > please don't remind me). For a very long time now I have wanted it to
> > > display a random slogan of my site from all of the possible slogans
> > > that are stored in my MySQL database. I have recently found out how
> > > to count the rows of a MySQL table and so I have made a script that
> > > will select an appropriate row (according to the list of rows 1-12 for
> > > example). BUT the problem I am having is that if i have a row that
> > > I've deleted then that row can still be selected, as I have no way
> > > (that I know) as to reference which rows are not deleted ..to be able
> > > to ONLY show the slogans and not just an empty row of nothingness.
>
> > > Is this possible, and if so, how?
>
> > > P.S.
> > > You can see the page which outputs the relevant random number here:
> > >http://flavouredcandy.com/page.php?id=2(itsjust under the right
> > > banner).
>
> > Use RAND() in MySQL to select a random slogan from the database.
>
> > $chosen_slogan = mysql_query('SELECT slogan_id FROM slogans ORDER BY
> > RAND() LIMIT 1');
>
> > --
> > Rik Wasmus
>
> I'll try that now, and if it works thats really really clever, thank
> you.
>
> James.

That worked perfectly, thank you so very much.

Thanks, James.