|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
Randomize mail from MySQL database Including this script does not work. I get the value -1 on Rand_nr and Number. Why it nit working. I have read a lot on this...still ![]() Code: strSQL = "SELECT lopnr, namn, enamn FROM tblTest" Set Rs = objConn.Execute(strSQL) If Rs.EOF Then Response.Write "Inga poster att slumpa ?n.." Rs.Close : Set Rs = Nothing Else With Rs .Close .Cursortype=3 .Open End With Antal = Rs.RecordCount Randomize Rand_nr = Int(Rnd * Antal) Rs.Move Rand_nr Response.Write ""&Antal & "" Response.Write ""&Rand_nr & "" Response.Write " "&Rs("id")&". "&Rs("namn")&", "&Rs("enamn")&" " Rs.Close : Set Rs = Nothing End If |
#2
| |||
| |||
Re: Randomize mail from MySQL database Code: Else With Rs .Close .Cursortype=3 .Open End With Can not bring Cursortype directly or use getRows instead and get number of responses then? |
#3
| |||
| |||
Re: Randomize mail from MySQL database Why not use rand () in mysql instead of ASP? What I mean is that you should ask the database to return what they want, instead of downloading everything and then manually do anything half hitch filter. select ID, Name, rand () AS random from table1 order by rand () Limit 1 This always gives a single post in response, and it is that at precisely the moment has the smallest value in the "coincidence". (Although not 100% correct, as the rand () value is in the SELECT statement has no meaning, you need not even enter it. That's the ORDER BY uses as it is interesting.) |
![]() |
|
Tags: database, mail, mysql |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to connect PHP to mySQL Database | Nathen | Tips & Tweaks | 2 | 17-07-2011 03:49 AM |
Manipulating MySQL database using PHP | blueprats | Guides & Tutorials | 1 | 30-04-2010 04:29 PM |
How to speed up the MySQL database | Kalanidhi | Software Development | 5 | 27-02-2010 01:33 AM |
Mysql Error : Can't connect to local mysql server through socket ' var lib mysql mysql.sock' 2 | roshan45 | Software Development | 3 | 07-11-2009 09:36 PM |
Restoring MySQL database | Sean J | Software Development | 5 | 18-02-2009 01:46 PM |