4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 Random display from database
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
therapy
Junior WebHelper
Junior WebHelper


Joined: 22 Jun 2003
Posts: 3
Location: Singapore

PostPosted: Sun Jun 22, 2003 6:34 am (20 years, 10 months ago) Reply with QuoteBack to Top

Crying or Very sad Sad

i have extract my information from the database and arrange in the order of have stock, out of stock, preorder... however, when i try to add in RAND after order by, it messed up my arrangement and did not randomize... can someone help me on it... i will really appreciated it....

my code...(i have delete the word RAND so as not to confuse you all...)

thanx...

<%
sql = " Select products.*, products.ccategory, categories.catdescription " &_
" FROM categories INNER JOIN products ON categories.categoryID=products.ccategory " &_
" WHERE products.ccategory= " & cInt(catID(j))
sql = sql & " ORDER BY products.stockquantity DESC, products.preorder ASC "
set rs = server.CreateObject("ADODB.Recordset")
rs.Open sql, dbc, adOpenForwardOnly,adLockReadOnly,adCmdText
%>
OfflineView User's ProfileFind all posts by therapySend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Jun 22, 2003 8:36 am (20 years, 10 months ago) Reply with QuoteBack to Top

Hello,

It is possible that the RAND() function only works if you don't specify the fields you wish to select (products.* instead of products.ccategory), as this is the case with MySQL.

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
therapy
Junior WebHelper
Junior WebHelper


Joined: 22 Jun 2003
Posts: 3
Location: Singapore

PostPosted: Sun Jun 22, 2003 1:37 pm (20 years, 10 months ago) Reply with QuoteBack to Top

i dun really understand... can you show me how... please... thanx... i'm not very good on such thing...thanx
OfflineView User's ProfileFind all posts by therapySend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Jun 22, 2003 1:40 pm (20 years, 10 months ago) Reply with QuoteBack to Top

I'm probably wasting your time, since I don't have a clue about the language and database you're using, but try replacing
Code:
sql = " Select products.*, products.ccategory, categories.catdescription " &_
" FROM categories INNER JOIN products ON categories.categoryID=products.ccategory " &_
" WHERE products.ccategory= " & cInt(catID(j))
with
Code:
sql = " Select products.*, categories.* " &_
" FROM categories INNER JOIN products ON categories.categoryID=products.ccategory " &_
" WHERE products.ccategory= " & cInt(catID(j))


and then trying the RAND function.

You never know, it just might work Cool

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
therapy
Junior WebHelper
Junior WebHelper


Joined: 22 Jun 2003
Posts: 3
Location: Singapore

PostPosted: Sun Jun 22, 2003 2:16 pm (20 years, 10 months ago) Reply with QuoteBack to Top

Sad sorry,... it is still not working... Question stress...
OfflineView User's ProfileFind all posts by therapySend Personal Message
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.123185 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme