PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 3rd, 2004, 09:10 AM
Scot Scot is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 29 Scot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 17 sec
Reputation Power: 0
Smile Help with incorporating function into MySQL query

I have a function which I am trying to incorporate into a MySQL query. I didn't write the function and I am only a newby at MySQL so I am totally lost. My question is how do I use the function below to allow the user to pick two dates which then are used to query the database for results between the two dates selected. Any and all suggestions are much appreciated! The function I am trying to use and the existing query into which I am trying to feed the selections are posted below. Thanks Again!

THE FUNCTION
===================
<?
function DateSelector($inName, $useDate=0)
{
/* create array so we can name months */
$monthName = array(1=>"January", "February", "March",
"April", "May", "June", "July", "August",
"September", "October", "November", "December");

/* if date invalid or not supplied, use current time */
if($useDate == 0)
{
$useDate = Time();
}

/* make month selector */
echo "<SELECT NAME=" . $inName . "Month>\n";
for($currentMonth = 1; $currentMonth <= 12; $currentMonth++)
{
echo "<OPTION VALUE=\"";
echo intval($currentMonth);
echo "\"";
if(intval(date("m", $useDate))==$currentMonth)
{
echo " SELECTED";
}
echo ">" . $monthName[$currentMonth] . "\n";
}
echo "</SELECT>";

/* make day selector */
echo "<SELECT NAME=" . $inName . "Day>\n";
for($currentDay=1; $currentDay <= 31; $currentDay++)
{
echo "<OPTION VALUE=\"$currentDay\"";
if(intval(date("d", $useDate))==$currentDay)
{
echo " SELECTED";
}
echo ">$currentDay\n";
}
echo "</SELECT>";

/* make year selector */
echo "<SELECT NAME=" . $inName . "Year>\n";
$startYear = date("Y", $useDate);
for($currentYear = $startYear - 5; $currentYear <= $startYear+5;$currentYear++)
{
echo "<OPTION VALUE=\"$currentYear\"";
if(date("Y", $useDate)==$currentYear)
{
echo " SELECTED";
}
echo ">$currentYear\n";
}
echo "</SELECT>";

}
?>
=============================

THE QUERY
=============================
$result = mysql_query( "SELECT * FROM ttime where ((SNUM = '".$_SESSION['SNUM']."') and ".$TIDATE." like '%".$TIDATEA."%') or ((SNUM = '".$_SESSION['SNUM']."') and ".$TIDATE." like '%".$TIDATEB."%') ORDER BY TIDATE ASC")
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "You currently have $num_rows time entries for "
=================================

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Help with incorporating function into MySQL query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT