need some PHP/mysql help please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • psyko514
    See sig. Join Epic Cash.
    • Oct 2002
    • 22366

    #1

    need some PHP/mysql help please

    I have database of a bunch of different galleries. I'm displaying links to these galleries in a table with the following code:
    PHP Code:
      $result = @mysql_query("SELECT * FROM $TableName WHERE approved = 'Y'");
      while ( $row = mysql_fetch_array($result) ) {
        $i++;
        echo "<td><a href=gallery.php?id=$row[id]>$row[name]</a><br>\n";</td>\n";
        if (($i % 5) == 0) { echo "</tr><tr>\n" ; } 
    
    i would like the table to have a different layout everytime it's loaded (i want the cells to be switched around)

    i've been racking my brain on this, and the only way i can think of is to select a random starting point in the database (which i have no idea how to do, or if it's possible)
    unless it's possible to rearrange an array.

    any help would be appreciated... just give me a shove in the right direction.
    if you want to write the code for me, i'll give you a cookie ;)
    thanks
    Last edited by psyko514; 01-04-2003, 01:38 AM.

    Bad Girl Bucks
    - 50% Revshare through CCBill.
    Promote BrandyDDD, Pixie's Pillows, Action Allie and more!

    Phoenix Forum Pics | Webmaster Access Montreal pics
    email: psyko514(a)gmail.com | icq: 214-702-014
  • Alky
    Confirmed User
    • Apr 2002
    • 5651

    #2
    im a little tired, but im guessing you just want it random instead of php pulling it with the same format everytime... if so use this:

    PHP Code:
    $result = @mysql_query("SELECT * FROM $TableName WHERE approved = 'Y' order by rand()");
      while ( $row = mysql_fetch_array($result) ) {
        $i++;
        echo "<td><a href=gallery.php?id=$row[id]>$row[name]</a>\n";</td>n";
        if (($i % 5) == 0) { echo "</tr><tr>n" ; } 
    

    Comment

    • psyko514
      See sig. Join Epic Cash.
      • Oct 2002
      • 22366

      #3
      perfect! thanks dude!
      your cookie is on it's way.

      Bad Girl Bucks
      - 50% Revshare through CCBill.
      Promote BrandyDDD, Pixie's Pillows, Action Allie and more!

      Phoenix Forum Pics | Webmaster Access Montreal pics
      email: psyko514(a)gmail.com | icq: 214-702-014

      Comment

      • Alky
        Confirmed User
        • Apr 2002
        • 5651

        #4
        thanks, i am kinda hungry

        Comment

        Working...