Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End PHP MySQL Rotating Ads

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #33451
    stevendeeds
    Member

    Hey doods. How should one go about creating rotating ads on a site using php/mysql? Just for clarity, I’m talking a random ad on load, not like.. some javascript that will change the ad while the user is on the page…

    #83299
    dhechler
    Member

    @TT_Mark has it right.


    SELECT * FROM table ORDER BY RAND() LIMIT 1;
    #83294
    stevendeeds
    Member

    Thanks @dhechler , Thanks @TT_Mark

    #83255
    dhechler
    Member

    @TT_MARK why would you never SELECT * ? If i need every single piece of data from a row, then I would SELECT *

    #83256
    dhechler
    Member

    @TT_MARK straight from dev.mysql.com

    A select list consisting only of a single unqualified * can be used as shorthand to select all columns from all tables:

    SELECT * FROM t1 INNER JOIN t2 ...
    #83220
    dhechler
    Member

    @TT_MARK I understand that you dont ALWAYS want to select everything, but your statement was that you should NEVER select everything. I was (and am) disagreeing with that. I have plenty of times where I need to get all columns out to either display or cache as a session variable.

    #83203
    ddliu
    Member

    @TT_Mark In fact “ORDER BY RAND” is very slow if performance counts.

    Here is a post on it: http://akinas.com/pages/en/blog/mysql_random_row/

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Back End’ is closed to new topics and replies.