Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,615 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 986 people online right now. Registration is fast and FREE... Join Now!




Help Mysql + Php

 
Reply to this topicStart new topic

Help Mysql + Php

arniie
post 29 Oct, 2002 - 05:39 AM
Post #1


D.I.C Addict

****
Joined: 8 Oct, 2002
Posts: 999

say ive got a db with a field for userimage (ie numbered 1, 2, 3, 4 )

how can i do a select statement that finds the most common userimage (the majority).

??
User is offlineProfile CardPM

Go to the top of the page

skrilla
post 29 Oct, 2002 - 05:56 AM
Post #2


boots.

*****
Joined: 5 Jul, 2002
Posts: 2,848



Dream Kudos: 14
My Contributions


be more specific, do you have a group of images that users can select from? so, say, they can choose:

-img1
-img2
or
-img3

??

if so, id do some clever things with eregi() and then dump the results into an array, then sort it, then read the array and bizzam. there ya go. if ya need more help, like writing the code and such, post again or email me or someone else tongue.gif

im getting ready to head off to second block though (school) so i cant be much help again until about 3 oclock or so. sorry :\
User is offlineProfile CardPM

Go to the top of the page

arniie
post 29 Oct, 2002 - 06:23 AM
Post #3


D.I.C Addict

****
Joined: 8 Oct, 2002
Posts: 999

that sounds good

can i do (for simpicity)

select count(fieldname) as countimage from tablename group by fieldname order by countimage desc limit 1
User is offlineProfile CardPM

Go to the top of the page

LuxFX
post 29 Oct, 2002 - 11:35 AM
Post #4


D.I.C Head

**
Joined: 9 Aug, 2001
Posts: 63

QUOTE(arniie @ Oct 29 2002, 09:23 AM)
select count(fieldname) as countimage from tablename group by fieldname order by countimage desc limit 1

have you tried this? this is what I was going to suggest and it seems to me that it should work fine. Does this give you problems?
User is offlineProfile CardPM

Go to the top of the page

arniie
post 29 Oct, 2002 - 11:40 AM
Post #5


D.I.C Addict

****
Joined: 8 Oct, 2002
Posts: 999

sorry should of posted - that works fine.

Another question,, is there a function to count active sessions? - i want to add 'no. of users online' without db connection.
User is offlineProfile CardPM

Go to the top of the page

Antisoft
post 19 Nov, 2002 - 04:15 AM
Post #6


D.I.C Head

**
Joined: 20 Jun, 2002
Posts: 71

It would be more simple to add a db connection and make it refresh everytime a user opens your site... perhaps u should log the IP too to make it more accurate. I've only heard of doing this via db but perhaps it is possible without a db.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 02:59AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month