Query in a database manipulation

Codes here !

Moderators: egami, macek, gesf

Post Reply
sathishgforum
New php-forum User
New php-forum User
Posts: 6
Joined: Tue Feb 17, 2004 9:19 pm
Contact:

Tue Feb 17, 2004 9:57 pm

Hi Pals,

Howz the day? Im a newbie to PHP but wants to learn quickly the baseline of the PHP-MYSQL
programming because of time-frame.So if anyone who have better knowledge in PHP-MYSQL can
change the following script from ASP to PHP-MYSQL.
---------------------------------------------------------
ASP CODE

set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "sample"
set rsprod = server.CreateObject("ADODB.Recordset")
rsprod.Open "select prd_nam from tbl_prod_details where psta =1 order by pdat desc",objConn,1,2

rsprod.MoveLast
cnt = rsprod.RecordCount
cnt1 = cnt
rndMax = cnt

If 6 < cnt Then
cnt1 = 6
End If

str = ","
str1 = ","
Do Until cnt1 = 0
Randomize
RndNumber = Int(Rnd * rndMax)

If (InStr(1, str1, "," & RndNumber & "," ) = 0) Then
str1 = str1 & RndNumber & ","
cnt1 = cnt1 - 1
rsprod.MoveFirst
rsprod.Move RndNumber
str = str & rsprod("prd_nam") & ","
End If

Loop

rsprod.Close
Set rsprod = Nothing

----------------------------------------------------------
Scenario is to get the random 6 names from the set of values in the database.Where <str> is
the variable to store the random numbers with delimiter of , (eg., Pepsi,Coke,Cake)
(Where Pepsi Coke Cake are stored in the database as a product name)

Any help would be greatly appreciated in this issue.

Cheers
SATHISH

liquedus
php-forum Active User
php-forum Active User
Posts: 264
Joined: Tue Apr 08, 2003 5:18 am
Location: Ottawa, Canada
Contact:

Wed Feb 18, 2004 6:53 pm

Howz the day? Im a newbie to PHP but wants to learn quickly the baseline of the PHP-MYSQL


Great click here then

Post Reply