[PHP-DB] Tutorial?
Hi all, Can anyone point me to a good tutorial on how to disable a submit button once clicked? preferably in php. Thanks Jennifer Downey -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Number of working hours in a month.
Hi there, Thanks, the article was posted by me at that site. I have a few different email addresses to a point I forgot which and which.. I have solved the problem. Here are the codes. 5 // // Initial formula doesn't work well, so I "reversed-engineered" to get the formula. // 0 - Sunday,...,6 - Saturday for ($year = 2001; $year <= 2037; $year++) { for ($month = 1; $month <= 12; $month++) { $num_of_days = date("t", mktime(0,0,0,$month,1,$year)); echo " Month=$month Year=$year "; echo "Number of days = $num_of_days "; $firstdayname = date("D", mktime(0, 0, 0, $month, 1, $year)); $firstday = date("w", mktime(0, 0, 0, $month, 1, $year)); $lastday = date("t", mktime(0, 0, 0, $month, 1, $year)); echo "First day of the month = $firstday,$firstdayname "; for ($day_of_week = 0; $day_of_week <= 6; $day_of_week++) { if ($firstday > $day_of_week) { // means we need to jump to the second week to find the first $day_of_week $d = (7 - ($firstday - $day_of_week)) + 1; } elseif ($firstday < $day_of_week) { // correct week, now move forward to specified day $d = ($day_of_week - $firstday + 1); } else { // my "reversed-engineered" formula if ($lastday==28) // max of 4 occurences each in the month of February with 28 days $d = ($firstday + 4); elseif ($firstday==4) $d = ($firstday - 2); elseif ($firstday==5 ) $d = ($firstday - 3); elseif ($firstday==6) $d = ($firstday - 4); else $d = ($firstday - 1); if ($lastday==29) // only 1 set of 5 occurences each in the month of February with 29 days $d -= 1; } $d += 28;// jump to the 5th week and see if the day exists if ($d > $lastday) { $weeks = 4; } else { $weeks = 5; } if ($day_of_week==0) echo "Sun "; elseif ($day_of_week==1) echo "Mon "; elseif ($day_of_week==2) echo "Tue "; elseif ($day_of_week==3) echo "Wed "; elseif ($day_of_week==4) echo "Thu "; elseif ($day_of_week==5) echo "Fri "; else echo "Sat "; echo "occurences = $weeks "; } // for $day_of_week loop } // for $mth loop } // for $year loop ?> At 04:16 PM 02-03-2002 -0800, Shrock, Court wrote: >I just ran across this description[1] that points to this link[2]. HAven't >tried it personally, and the site requires a login, so you might not find it >useful, but just in case. > >[1]Count how many weeks in the month have a specified day, such as Mon, Tue, >etc. Var avail - number of days - first dayname of the month, occurences of >Sun, occurences of Mon, etc. Allows you to calculate number of working hours >exclude Holidays. >[2] http://www.weberdev.com/get_example.php3?count=3267 > >-Original Message- >From: Hoo Kok Mun >To: [EMAIL PROTECTED] >Sent: 3/2/02 1:31 AM >Subject: [PHP-DB] Number of working hours in a month. > >Dear all, > >How do I dynamically calculate how many working hours in a particular >month? >Has anyone do it before? > >Here is the simple formula. >Add - Number of days in a month >Deduct - Sundays >Number of Mon-Fri in a month * 8 hours >Number of Sat in a month * 4 hours >My Figure = total working hours of a month. >I do not need to include any holidays. > >This data is for my monthly timesheets. >Currently I am hard coding it while I find a solution... > >I have almost managed to get the info that I wanted. >Below is the script and it works almost for all the months except for >some... >I would say about 92%, 1 in 12 incorrect... > >Can anyone help to debug and find a formula to get this working? > >$month=11; >$year=2002; > >$num_of_days = date("t", mktime(0,0,0,$month,1,$year)); >echo "Month=$month Year=$year "; >echo "Number of days = $num_of_days "; > >// count how many weeks in the month have a specified day, such as >Monday. >// we know there will be 4 or 5, so no need to check for $weeks<4 or >$weeks>5 > >$firstdayname = date("D", mktime(0, 0, 0, $month, 1, $year)); >$firstday = date("w", mktime(0, 0, 0, $month, 1, $year)); >$lastday = date("t", mktime(0, 0, 0, $month, 1, $year)); >echo "First day of the month = $firstdayname "; > >for ($day_of_week = 0; $day_of_week <= 6; $day_of_week++) >{ > if ($firstday > $day_of_week) { > // means we need to jump to the second week to find the first >$day_of_week > $d = (7 - ($firstday - $day_of_week)) + 1; > echo "d=$d "; > } elseif ($firstday < $day_of_week) { > // correct week, now move forward to specified day > $d = ($day_of_week - $firstday + 1); > echo "d=$d "; > } else {// $firstday = $day_of_week > // correct day in first week > $d = ($firstday - 1); > echo "d=$d "; > } > > $d += 28;// jump to the 5th week and see if the day exists > echo "(Final D=$d > $lastday) "; > if ($d > $lastday) { > $weeks = 4; > } else { > $weeks = 5; > } > echo "$d
Re: [PHP-DB] Retrieving a date.
On Saturday 02 March 2002 16:13, DL Neil wrote: > Ken, > > Check out DAYOFMONTH() and MONTH() and a wealth of other useful date > functions. RTFM: 6.3.4 Date and Time Functions There's a few interesting items here OK, Thanks for the pointer. > The answer to your question about AUTO_INCREMENT 'reset' can be found at > 6.5.3 CREATE TABLE Syntax under "table_options". EH? It says what?? I'm so green that this makes NO sense at all. Regards,table_options: TYPE = {BDB | HEAP | ISAM | InnoDB | MERGE | MRG_MYISAM | MYISAM } or AUTO_INCREMENT = # > =dn -- Ken Thompson, North West Antique Autos Payette, Idaho Email: [EMAIL PROTECTED] http://www.nwaa.com Sales and brokering of antique autos and parts. Linux- Coming Soon To A Desktop Near You Registered Linux User #183936 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Retrieving date, partially solved
Ken, If it works, it works! If you want to store the birthdate in a single column in the db, then make the datatype a date in CCYY-MM-DD format, then prepare the query by asking PHP for the server's date as month (MM) and day (DD) and apply those to the query using the functions I pointed you at earlier. Is it 'better'? You're the best judge! =dn > I have the thing returning the date as long as the date format is "m/d" in > the table with a seperate year column. > Here's the table: > > mysql> select * from Cinfo; > +-++--+---+---+ > | Cid | Fname | Lname| Bday | Byear | > +-++--+---+---+ > | 1 | Lars | Larsen | 03/02 | 1960 | > | 2 | Larry | Loophole | 03/02 | 1950 | > | 3 | Fuzzy | Wimp | 03/02 | 1990 | > | 4 | Willy | Warp | 03/03 | 1960 | > | 5 | Harry | Toes | 03/03 | 1998 | > | 6 | Jiminy | Cricket | 03/04 | 1889 | > +-++--+---+---+ > 6 rows in set (0.00 sec) > > Here's the code, I would welcome comments or improvements. > > $db = mysql_connect("localhost", "root"); > $Date = date("m/d"); > mysql_select_db("customers",$db); > > $result = mysql_query("SELECT * FROM Cinfo WHERE Bday = '$Date'"); > > The result is sent to a table and to my surprise actually works... > -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Retrieving date, partially solved
I have the thing returning the date as long as the date format is "m/d" in the table with a seperate year column. Here's the table: mysql> select * from Cinfo; +-++--+---+---+ | Cid | Fname | Lname| Bday | Byear | +-++--+---+---+ | 1 | Lars | Larsen | 03/02 | 1960 | | 2 | Larry | Loophole | 03/02 | 1950 | | 3 | Fuzzy | Wimp | 03/02 | 1990 | | 4 | Willy | Warp | 03/03 | 1960 | | 5 | Harry | Toes | 03/03 | 1998 | | 6 | Jiminy | Cricket | 03/04 | 1889 | +-++--+---+---+ 6 rows in set (0.00 sec) Here's the code, I would welcome comments or improvements. $db = mysql_connect("localhost", "root"); $Date = date("m/d"); mysql_select_db("customers",$db); $result = mysql_query("SELECT * FROM Cinfo WHERE Bday = '$Date'"); The result is sent to a table and to my surprise actually works... -- Ken Thompson, North West Antique Autos Payette, Idaho Email: [EMAIL PROTECTED] http://www.nwaa.com Sales and brokering of antique autos and parts. Linux- Coming Soon To A Desktop Near You Registered Linux User #183936 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Number of working hours in a month.
I just ran across this description[1] that points to this link[2]. HAven't tried it personally, and the site requires a login, so you might not find it useful, but just in case. [1]Count how many weeks in the month have a specified day, such as Mon, Tue, etc. Var avail - number of days - first dayname of the month, occurences of Sun, occurences of Mon, etc. Allows you to calculate number of working hours exclude Holidays. [2] http://www.weberdev.com/get_example.php3?count=3267 -Original Message- From: Hoo Kok Mun To: [EMAIL PROTECTED] Sent: 3/2/02 1:31 AM Subject: [PHP-DB] Number of working hours in a month. Dear all, How do I dynamically calculate how many working hours in a particular month? Has anyone do it before? Here is the simple formula. Add - Number of days in a month Deduct - Sundays Number of Mon-Fri in a month * 8 hours Number of Sat in a month * 4 hours My Figure = total working hours of a month. I do not need to include any holidays. This data is for my monthly timesheets. Currently I am hard coding it while I find a solution... I have almost managed to get the info that I wanted. Below is the script and it works almost for all the months except for some... I would say about 92%, 1 in 12 incorrect... Can anyone help to debug and find a formula to get this working? "; echo "Number of days = $num_of_days "; // count how many weeks in the month have a specified day, such as Monday. // we know there will be 4 or 5, so no need to check for $weeks<4 or $weeks>5 $firstdayname = date("D", mktime(0, 0, 0, $month, 1, $year)); $firstday = date("w", mktime(0, 0, 0, $month, 1, $year)); $lastday = date("t", mktime(0, 0, 0, $month, 1, $year)); echo "First day of the month = $firstdayname "; for ($day_of_week = 0; $day_of_week <= 6; $day_of_week++) { if ($firstday > $day_of_week) { // means we need to jump to the second week to find the first $day_of_week $d = (7 - ($firstday - $day_of_week)) + 1; echo "d=$d "; } elseif ($firstday < $day_of_week) { // correct week, now move forward to specified day $d = ($day_of_week - $firstday + 1); echo "d=$d "; } else {// $firstday = $day_of_week // correct day in first week $d = ($firstday - 1); echo "d=$d "; } $d += 28;// jump to the 5th week and see if the day exists echo "(Final D=$d > $lastday) "; if ($d > $lastday) { $weeks = 4; } else { $weeks = 5; } echo "$day_of_week occurences = $weeks "; } ?> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Anyone with suggestions to make this run faster?
hey folks, I just got done writing a function to help with my data cleaning. It works - actually a lot better than I thought it would - but I am sure there are ways I could optimize this somewhat. The function takes two result sets (usually first name, last name, city, state, zip) from two tables, then calculates the similar_text() value for each pair (first name from table one, versus first name from table two, and so forth) and places those values into a new table. What I end up with is a sort of fuzzy matching lookup table, so I could look up all values where there is a 90 percent match in each category (for example), and then use that to update my original tables. Hope that makes sense. Anyway, here's the code. If anyone has any suggestions (such as, is it faster to dump into a local file and then move that into a table?), I'm all ears. Thanks in advance: -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Retrieving a date.
Ken, Check out DAYOFMONTH() and MONTH() and a wealth of other useful date functions. RTFM: 6.3.4 Date and Time Functions The answer to your question about AUTO_INCREMENT 'reset' can be found at 6.5.3 CREATE TABLE Syntax under "table_options". Regards, =dn > I have a test table with the ususal customer information in it along with a > field for the date of birth. I'm trying to return records of any customers > whose birthdates are the same day and month as the current date. > Here's the query & result: > mysql> SELECT * FROM Cinfo WHERE BirthDate = "date('m d')"; > Empty set (0.00 sec) > Here's what is returned with a global query: > mysql> select * from Cinfo; > +---+--+---+-+---++- -+--+--+++ > | FirstName | LastName | Address | City| State | Zip | > HomePhone| WorkPhone| CellPhone| BirthDate | id | > +---+--+---+-+---++- -+--+--+++ > | Joe | Blow | 1200 High St. #12 | St.Looy | UT| 844110 | > 801-111-2299 | 801-111-3456 | 801-213-8956 | 1959-03-01 | 1 | > | | | | | | | >| | || 2 | > | | | | | | | >| | || 3 | > | | | | | | | >| | || 4 | > +---+--+---+-+---++- -+--+--+++ > 4 rows in set (0.00 sec) > > I have a feeling it's the date format in the table. I tried making it a date > field but just got the current date. What am I doing wrong? > Off Topic, I saw something about resetting the auto-increment counter, but > now I can't find reference to it. Can some kind soul enlighten me??? > -- > > > Ken Thompson, North West Antique Autos > Payette, Idaho > Email: [EMAIL PROTECTED] > http://www.nwaa.com > Sales and brokering of antique autos and parts. > > Linux- Coming Soon To A Desktop Near You > Registered Linux User #183936 > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Force Refresh on Another Window w/ Javascript
Instead of just closing the window try this : Echo"opener.location.reload(); window.close(); "; Sincerely berber Visit http://www.weberdev.com Today!!! To see where PHP might take you tomorrow. -Original Message- From: Shahmat Dahlan [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 8:36 AM To: PHP-DB Subject: [PHP-DB] Force Refresh on Another Window w/ Javascript Importance: High I have a question, let's say i have my main page (so called) called "index.php". I have also displayed a buttonin index.php, which i will used the "onClick" event to trigger a "window.open" function to the same main page, "index.php" (but with parameters). so my index.php should have these codes <% ... ... if( $action == addnew ) { ... } else { } %> NOTE: i'm using asp tags set in php.ini during the adding of new records, i have also display another button called "Close Window". And when I close this, how do i force the main page (which is in a different window to refresh, to display the newly added records). This is because after I have closed the add new records window, and close it, i would have to have either a refresh button or you would have to refresh it yourself. And thanks in advance. regards -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Difficult count statement. Need some sql advice
Well off the top I'd say your forgot the join condition between the fo_topics and the fo_forums tables. Right now you're counting the Cartesian product of the two tables. Also you can't select an aggregate function (like count) and regular columns without a group by on the same columns. F on 3/2/02 8:37 AM, [EMAIL PROTECTED] at [EMAIL PROTECTED] wrote: > From: "Andy" <[EMAIL PROTECTED]> > Reply-To: "Andy" <[EMAIL PROTECTED]> > Date: Sat, 2 Mar 2002 17:36:41 +0100 > To: [EMAIL PROTECTED] > Subject: Difficult count statement. Need some sql advice > > Hi there, > > I would like to querry my db for following result > > - Count the number of topics listed in the table fo_topics, > but only the topics where the belonging forum is not in the archive mode > ( this is when table fo_forums field archive is 1) > > I tryed following querry but this is for sure wrong: > > SELECT COUNT(t.*) AS c, f.archive, f.forum_id > FROM fo_topics t, fo_forums f > WHERE f.archive != 1 > > Can this be that difficult? > > Thanx for any help > > Andy > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Difficult count statement. Need some sql advice
On Sat, Mar 02, 2002 at 05:36:41PM +0100, Andy wrote: > Hi there, > > I would like to querry my db for following result > > - Count the number of topics listed in the table fo_topics, > but only the topics where the belonging forum is not in the archive mode > ( this is when table fo_forums field archive is 1) > > I tryed following querry but this is for sure wrong: > > SELECT COUNT(t.*) AS c, f.archive, f.forum_id > FROM fo_topics t, fo_forums f > WHERE f.archive != 1 > > Can this be that difficult? > > Thanx for any help > > Andy You need to join the two tables together: select count(t.*) as c, f.archive, f.forum_id from fo_topics t, fo_forums f where t.forum_id = f.forum_id and f.archive != 1 might work. I assume you have a foreign key in fo_topics linking to fo_forums. Bill -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Difficult count statement. Need some sql advice
Hi there, I would like to querry my db for following result - Count the number of topics listed in the table fo_topics, but only the topics where the belonging forum is not in the archive mode ( this is when table fo_forums field archive is 1) I tryed following querry but this is for sure wrong: SELECT COUNT(t.*) AS c, f.archive, f.forum_id FROM fo_topics t, fo_forums f WHERE f.archive != 1 Can this be that difficult? Thanx for any help Andy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Display in drop-down box
Hi there:) I use odbc so you'll have to change your functions if you're using mysql //connect to db $connectionToDB = odbc_connect("cdconsultant", "joecon", "joecon"); //create query statement $sqlr = "SELECT DISTINCT category FROM CONSULTANT ORDER BY category" ; //execute the sql statement (query) on the connection made $resultset = odbc_do($connectionToDB, $sqlr); print ""; //loop through the category field and dump into select box while(odbc_fetch_row($resultset)){ $category = odbc_result($resultset,1); print "$category"; } print "Category"; print ""; print ""; // close the connection odbc_close($connectionToDB); Hope this helps, Joe :) Alvin Ang <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED].; > Hi there, > > I was wondering if anyone would be kind enough to show me how to select a > field from a table in mysql and display it in a drop-down combo box? > > I am trying to show my users a list of all the parts from a table so that > they can edit or delete it. > > Thanks! > > Alvin > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Number of working hours in a month.
Dear all, How do I dynamically calculate how many working hours in a particular month? Has anyone do it before? Here is the simple formula. Add - Number of days in a month Deduct - Sundays Number of Mon-Fri in a month * 8 hours Number of Sat in a month * 4 hours My Figure = total working hours of a month. I do not need to include any holidays. This data is for my monthly timesheets. Currently I am hard coding it while I find a solution... I have almost managed to get the info that I wanted. Below is the script and it works almost for all the months except for some... I would say about 92%, 1 in 12 incorrect... Can anyone help to debug and find a formula to get this working? "; echo "Number of days = $num_of_days "; // count how many weeks in the month have a specified day, such as Monday. // we know there will be 4 or 5, so no need to check for $weeks<4 or $weeks>5 $firstdayname = date("D", mktime(0, 0, 0, $month, 1, $year)); $firstday = date("w", mktime(0, 0, 0, $month, 1, $year)); $lastday = date("t", mktime(0, 0, 0, $month, 1, $year)); echo "First day of the month = $firstdayname "; for ($day_of_week = 0; $day_of_week <= 6; $day_of_week++) { if ($firstday > $day_of_week) { // means we need to jump to the second week to find the first $day_of_week $d = (7 - ($firstday - $day_of_week)) + 1; echo "d=$d "; } elseif ($firstday < $day_of_week) { // correct week, now move forward to specified day $d = ($day_of_week - $firstday + 1); echo "d=$d "; } else {// $firstday = $day_of_week // correct day in first week $d = ($firstday - 1); echo "d=$d "; } $d += 28;// jump to the 5th week and see if the day exists echo "(Final D=$d > $lastday) "; if ($d > $lastday) { $weeks = 4; } else { $weeks = 5; } echo "$day_of_week occurences = $weeks "; } ?> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] easy date format question
or : $sql="INSERT INTO table (date) VALUES (now())"; -Original Message- From: Jim Lucas [php] [mailto:[EMAIL PROTECTED]] Sent: Saturday, March 02, 2002 2:11 AM To: [EMAIL PROTECTED]; Matthew Crouch Subject: Re: [PHP-DB] easy date format question $today = date("Ymd"); $sql = "INSERT into table (date) values ('$today')"; when the $today variable is inserted into a mysql date column it will fit just right. but, if you want to insert it into a timestamp column, you will have to padd it with 6 zero's Jim Lucas www.bend.com - Original Message - From: "Matthew Crouch" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, March 01, 2002 2:50 PM Subject: [PHP-DB] easy date format question > should be simple as pie, of course, but i can't find a straightforward > syntax example in the documentation. i'm trying to change the PHP date > format to mysql's. > > my code: > $today = date("MMDD"); > $sql = "INSERT into table (date) values ('$today')"; > and so on... > > is filling the date field with zeros, instead of 2002-02-28 > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Security concern with web forms (update of MySQL data base)
1st, you should limit the permissions that you have for the user doing the update. This user should not be able to do things like ALTER / DROP / CREATE etc... If you don't have a need for the DELETE command you can remove the permissions for it to, however this does not solve all of your problems since UPDATE can do as much harm as DELETE. You should use ' ' around all of your variables (even integers) so that if anyone tries some funny business with ";" it will fail. You should also do as much data validation as you can. Make sure that you are actually getting integers where you expect them etc... For someone to be able to mess your DB, he needs to know your db scheme so try to keep away from obvious field names and make it harder for that someone to guess your table / field names. Sincerely berber Visit http://www.weberdev.com Today!!! To see where PHP might take you tomorrow. -Original Message- From: Ronald Wiplinger [mailto:[EMAIL PROTECTED]] Sent: Saturday, March 02, 2002 4:00 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Security concern with web forms (update of MySQL data base) A php page, which includes an update statement for a MySQL data base: I am trying to figure out, how I can make sure that an update form on the web cannot include codes, that would update other parts of the database (or worse destroy a database). bye Ronald Ronald Wiplinger (ÃQ¤¯¯Ç), CEO, ELMIT - The Solution Provider Tel. +886 2 8809-7680, Fax. +886 2 2809-0183, Mobile: +886 915 653-452 Net2Phone:8869550066, ICQ: 111651169 http://www.elmit.comhttp://www.wiplinger.org -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php