Net123 Posted February 7, 2011 Share Posted February 7, 2011 How to i generate a random file from files table using php and sql do you know please post here ? Link to comment Share on other sites More sharing options...
boen_robot Posted February 7, 2011 Share Posted February 7, 2011 Generate what from what?What is "random file" supposed to mean? Random file name for a certain known file with certain data? Or a file with certain name with some kind of contents based on random data?By "files table" do you mean a table in an SQL database which contains... what? File paths of some sort? Link to comment Share on other sites More sharing options...
Net123 Posted February 7, 2011 Author Share Posted February 7, 2011 I have stored my file's from 'files' table to my server just i wanna generate a name from the record's can you help me Link to comment Share on other sites More sharing options...
justsomeguy Posted February 7, 2011 Share Posted February 7, 2011 Are you trying to get a random record from the table? Link to comment Share on other sites More sharing options...
birbal Posted February 7, 2011 Share Posted February 7, 2011 do you have any unique id associated with file name in db? Link to comment Share on other sites More sharing options...
Net123 Posted February 7, 2011 Author Share Posted February 7, 2011 yes i am using this code 'id' int(11) NOT NULL auto_increment,'path' text NOT NULL,'infolder' text NOT NULL,'name' varchar(255) NOT NULL,......... etc etc Link to comment Share on other sites More sharing options...
justsomeguy Posted February 7, 2011 Share Posted February 7, 2011 If you're trying to get a random record, you can do this:SELECT * FROM files ORDER BY RAND() LIMIT 1 Link to comment Share on other sites More sharing options...
birbal Posted February 7, 2011 Share Posted February 7, 2011 then you can use rand to generate a random number. then query with it appending the number in WHERE caluse...something like SELECT * FROM table WHERE id=somerandnumber Link to comment Share on other sites More sharing options...
Net123 Posted February 7, 2011 Author Share Posted February 7, 2011 But how to i generate a file name from files table (not a random number )i want to generate an file name from my server using sql Link to comment Share on other sites More sharing options...
justsomeguy Posted February 7, 2011 Share Posted February 7, 2011 You're going to need to give examples. Why does SQL need to generate the name? Link to comment Share on other sites More sharing options...
Net123 Posted February 7, 2011 Author Share Posted February 7, 2011 Wow really very thanks bro i gonna for try this If you're trying to get a random record, you can do this:SELECT * FROM files ORDER BY RAND() LIMIT 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.