Webmaster Forums 101 - Free Help and Discussions
 
 
 

MEMBER REWARDS - Earn free advertising by participating in these forums! Click here for details.

Welcome to Webmaster Forums 101!

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

Reply
 
Thread Tools Search this Thread Display Modes
Old 26th September 2005, 03:45 PM   #1

Username: Ben
Rank: WF101 Fanatic
Join Date: Jan 2005
Posts: 181
Points: 26.24
Wink Selecting unique "timestamp"s from a MySQL Database

Hey there...

I have a script that allows someone to add the service times for a chuch into database using time(). There are normally about three church services on the same day.

Basically there is a form where they select the day, month and year. When adding the service to the database, I use this code to convert the service times into timestamp:

PHP Code:
$service_datday mktime(000$HTTP_POST_VARS[month], $HTTP_POST_VARS[day], $HTTP_POST_VARS[year]);
$service_dattime mktime($hour$HTTP_POST_VARS[minute], 0$HTTP_POST_VARS[month], $HTTP_POST_VARS[day], $HTTP_POST_VARS[year]); 

The database tables:

Code:
service_intid service_strname service_datday service_dattime

That all works fine... But now with the question...

Basically what I want to do is select four of the up coming services from the database. That's easy except some days, like I said above, have three services on that one day... So three of the service_datday would be exactly the same because the service is on the same day. I only want to select one of those three from the database.

So basically I would need something like this... This is just a guess of how it would work...

PHP Code:
$query mysql_query("select * from {$tbl_name}services order by unique(service_datday) desc") or die("<b>MySQL Error:</b> ".mysql_error());
while(
$row mysql_fetch_array($query)) {
ect... 

I'm not sure what to use instead of unique(service_datday).

Hopefully that all makes sense

Cheers
Ben is offline   Reply With Quote
Old 27th September 2005, 11:00 AM   #2
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

Try this:

Code:
select DISTINCT(service_datday) from {$tbl_name}services order by service_datday desc
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Old 30th September 2005, 12:30 PM   #3

Username: Ben
Rank: WF101 Fanatic
Join Date: Jan 2005
Posts: 181
Points: 26.24
Default

That's exactly what I needed! Thanks!
Ben is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Login
User Name
Password


Featured Members


Featured Links


Useful Resources
Webmaster Resources
Developers Tools
Developer Tutorials


Partners

All times are GMT +10. The time now is 09:34 AM.


Powered by vBulletin Version 3.5.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.3.2
 
 
WEBMASTER FORUMS 101
ARCHIVE
CONTACT US
TOP
   
© Webmaster Forums 101 2005. All Rights Reserved.
Design by: vBCore