#1
  1. No Profile Picture
    Francine
    Guest
    Devshed Newbie (0 - 499 posts)
    I want to add a file to many of my pages (i know to use include file to do this already) but i want it to be a randomly generated quote from my database. How do I make it random which quote pops up?
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    24
    Rep Power
    0
    what database r u using ??
  4. #3
  5. No Profile Picture
    Francine
    Guest
    Devshed Newbie (0 - 499 posts)
    MySQL
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    24
    Rep Power
    0
    Just check the mysql version .... the latest version has this feature ....

    use can use :
    select * from tablename order by rand()


    But if the above doesn't work then the version of mysql doesn't have the random feature .... there is another way around it

    firstly u have to have an auto increment column (won't work if u dont) .. say its called ID. Then the sql statement u would use would be:

    select *, ID*0+rand() as rand_col from tablename order by rand_col

  8. #5
  9. No Profile Picture
    Francine
    Guest
    Devshed Newbie (0 - 499 posts)
    Thank you!

Similar Threads

  1. Selecting a random row
    By TomGillespie in forum MySQL Help
    Replies: 3
    Last Post: February 16th, 2004, 07:34 AM
  2. how to keep table on top, not centered??
    By vinyl in forum HTML Programming
    Replies: 2
    Last Post: January 20th, 2004, 06:19 PM
  3. Changing color of table row with checkbox
    By JessJenn in forum HTML Programming
    Replies: 8
    Last Post: January 9th, 2004, 09:08 AM
  4. Replies: 3
    Last Post: December 23rd, 2003, 01:05 PM
  5. Replies: 0
    Last Post: December 20th, 2003, 02:41 AM

IMN logo majestic logo threadwatch logo seochat tools logo