This is the code I'm using to display from my table

("SELECT vmplay_videos.id, vmplay_videos.artistid, vmplay_artists.artistfirst, vmplay_artists.artistlast, vmplay_videos.songname FROM vmplay_artists, vmplay_videos WHERE vmplay_artists.id = vmplay_videos.artistid and videoactive = 'yes' ORDER BY RAND( NOW( ) )  LIMIT 5 ");

But is there anyway of only displaying 5 records of based on only one specific 'artisitid' but it being random

So for example.

The php calls from the table selects a specific id and only shows 5 records based on the id it has just randomly selected?

    Some of your column names didnt match up in the query, so I renamed them in this new query. If I misnamed the columns, you should still get the point of how to write the query. 🙂

    $sql = "SELECT va.id, vv.artistid, va.artistfirst, va.artistlast, vv.songname ";
    $sql .= "FROM vmplay_artists AS va, vmplay_videos AS vv WHERE ";
    $sql .= "va.id IN (SELECT artistid FROM vmplay_videos ORDER BY RAND()) ":
    $sql .= "AND vv.videoactive = 'yes' ORDER BY RAND(NOW()) LIMIT 0,5");

      Cheers, but this is throwing back an error message.

      Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.sites/107/site221/web/testingnewlayout2.php on line 256

      All the names for the colums are correct.

        Post the code where you run the query and then start grabbing results. You haven't suppressed any error messages earlier that might help, have you?

          <? 
          $result = mysql_query("SELECT vv.id, vv.artistid, va.artistfirst, va.artistlast, vv.songname FROM vmplay_artists AS va, vmplay_videos AS vv WHERE va.id IN (SELECT artistid FROM vmplay_videos ORDER BY RAND()) AND vv.videoactive = 'yes' ORDER BY RAND(NOW()) LIMIT 0,5"); 
          while($row = mysql_fetch_array($result)){
          $song = $row["songname"]; 
          $aid = $row["artistid"];
          $vid = $row["id"]; 
          echo "<span class=\"pinklight\"><a href=\"#\"  onclick=\"window.open('/test-videowindowsmedia.php?artistid=".$aid."&vidid=".$vid."&speed=wmvhi','video','top=50,left=50,');  return false;\">".$song."</a></span><br>"; 
          } 
          ?>

          Thats How I'm calling it

            Have you tried using [man]mysql_error[/man] yet?

              Yup

              A fatal MySQL error occured. 
              Query: 
              Error: (1064) You have an error in your SQL syntax near 'SELECT artistid FROM vmplay_videos ORDER BY RAND()) AND vv.videoactive = 'yes' O' at line 1

              Any ideas?

                At a guess .. you're using MySQL 3.xx .. which doesn't support sub-selects.

                  What a Shock!

                  Yes this is the reason.
                  I'm now emailing my hoster to demand that my needs are met!
                  Here's hoping!

                    Write a Reply...