WordPress.org

Ready to get started?Download WordPress

Forums

Setting up a SQL table for random select (2 posts)

  1. hinoiri
    Member
    Posted 9 years ago #

    I want to use this (from here):

    $sql = "SELECT * FROM blogroll ORDER BY rand(" . time() . " * " . time() . ") LIMIT 1";

    In order to pull bits of random code into my sidebar.php file (I will need to use lots of these random entries, so this method looks best, ATM).

    Do I use this by creating a table in my WP database and replacing "blogroll" in the above line with the name of the table(say: randomphp)?

    I will try this as soon as I figure out how to fill in the fields in the new table.

    If I am correct about what I need to do please help me out with the fields on the table creation screen in phpMYadmin:

    Field?
    The code I want to put in place of the SQL string in my sidebar.php, right?

    Type?

    Length/Values*?

    Attributes?

    Null?

    Default**?

    Extra?

    primary, index, unique, or ---?

    full text?

  2. hinoiri
    Member
    Posted 9 years ago #

    I think I picked the hardest way to do what I wanted, but I found the easy way.

    Using random file include will give me all the random goodness I will need for my current desires.

    http://www.phpfreaks.com/quickcode/code/50.php

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.