Random Value for SQL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Random Value for SQL

    $pot = mysql_fetch_array(mysql_query("SELECT pid FROM ibwf_albumpic WHERE private='0' ORDER BY rand() LIMIT 1"));

    $new = mysql_fetch_array(mysql_query("SELECT MAX(pid) FROM ibwf_albumpic WHERE private='0'"));

    is that correct?

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kendee/public_html/wap/v2/album.php on line of $pot

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kendee/public_html/wap/v2/album.php on line of $new

    for $pot
    i just want to get random pid in ibwf_albumpic for 1day (picture of the day)

    and for $new
    i just want to get the maximum value of pid to get the newest pid or order by time
    Did I help you?
    You can help me too
    Your donations will help me finance my studies.

    #2
    the query looks fine whats the contents of ya table like rows etc

    Comment


      #3
      be sure that ur SqL is correct lol ....try this

      $pot = mysql_fetch_array(mysql_query("SELECT DISTINCT pid FROM ibwf_albumpic WHERE private='0' ORDER BY RAND() LIMIT 1"));
      or

      $pot = mysql_fetch_array(mysql_query("SELECT DISTINCT id FROM ibwf_albumpic WHERE private='0' ORDER BY RAND() LIMIT 1"));

      or

      $pot = mysql_fetch_array(mysql_query("SELECT DISTINCT id, uid FROM ibwf_albumpic WHERE private='0' ORDER BY RAND() LIMIT 1"));

      Comment


        #4
        Code:
        SELECT pid FROM table WHERE private='0' ORDER BY time DESC LIMIT 1

        Comment


          #5
          Originally posted by thanatos View Post
          Code:
          SELECT pid FROM table WHERE private='0' ORDER BY time DESC LIMIT 1
          this in not random ..... it place 1st or last photo

          Comment


            #6
            look at his post.. he wants to get newest value of pid..

            Comment


              #7
              ah ok dude ...i dont see bout that i just look @ the title

              Comment


                #8
                the 1st query is for random result 2nd is for pid value

                Comment


                  #9
                  Originally posted by ori View Post
                  the query looks fine whats the contents of ya table like rows etc
                  thanks for that info! i think i got a heavy stress

                  Originally posted by ZED View Post
                  be sure that ur SqL is correct lol ....try this

                  $pot = mysql_fetch_array(mysql_query("SELECT DISTINCT pid FROM ibwf_albumpic WHERE private='0' ORDER BY RAND() LIMIT 1"));
                  or

                  $pot = mysql_fetch_array(mysql_query("SELECT DISTINCT id FROM ibwf_albumpic WHERE private='0' ORDER BY RAND() LIMIT 1"));

                  or

                  $pot = mysql_fetch_array(mysql_query("SELECT DISTINCT id, uid FROM ibwf_albumpic WHERE private='0' ORDER BY RAND() LIMIT 1"));
                  thanks for the red font same comment

                  Originally posted by thanatos View Post
                  Code:
                  SELECT pid FROM table WHERE private='0' ORDER BY time DESC LIMIT 1
                  thanks for the reply

                  by the way i got wrong column thanks to all =)
                  Did I help you?
                  You can help me too
                  Your donations will help me finance my studies.

                  Comment

                  Working...
                  X