
potato_chip
Members-
Posts
11 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
potato_chip's Achievements

Newbie (1/5)
0
Reputation
-
(yeah, I know it sounds ridiculous that the table has more than 100 fields, but this is a very complicated system and that's how the thing works here.) My problem is: the filed I want to update is part of the key. If you could give me a sample example, that will be great!
-
What I want to do is: first: copy one record from a table with certain creteria second: just update two fileds third: insert this new record into the same table This talbe has more than 100 fields, can somebody please show me how to write the query? Thank you very much!
-
thank you!
-
I need to test this simple javascript form validation code before doing actually work to insert data into database. However, I don't know why this very simple validation code is not working. It looks like the formValidate() function is never called. I have searched online, and compared code line by code, still couldn't figure out what's wrong. :injured: here is my form: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script language="javascript" type="text/javascript"> function formValidate(frm) { alert("come to form validate"); var errorFlag = false; var errorMsg = ""; var tbl = document.getElementById('tblTimesheet'); var numOfRows = tbl.tBodies[0].rows.length; alert("num of rows = " + numOfRows); for (i=1; i<=numOfRows; i++) { var empNameValue = document.getElementById('empName' + i).value; var noteValue = document.getElementById('note' + i).value; var hoursValue = document.getElementById('hours' + i).value; if( empNameValue == "" || noteValue == "" || hoursValue == "" ) { errorMsg = "can not leave any field empty."; errorFlag = true; } } if(errorFlag == true) { alert(errorMsg); return false; } else { document.getElementById('numOfRowsSubmit').setAttribute("value",numOfRows); //return true; //submit form frm.submit(); } } } </script> </head> <body> <form action="dosomthing.php" method="post" name="myfrm"> <input type="hidden" name="check_submit" value="1" /> <input type="hidden" name="numOfRowsSubmit" id="numOfRowsSubmit" value="" /> <input type="button" value="Save" onclick="formValidate(this.form)" /> <table id="tblTimesheet"> <thead> <tr><th>name</th><th>note</th><th>hours</th></tr> </thead> <tbody> <tr> <td><input type="text" name="empName1" id="empName1" size="30" /></td> <td><input type="text" name="note1" id="note1" size="30" /></td> <td><input type="text" name="hours1" id="hours1" size="30" /></td> </tr> <tr> <td><input type="text" name="empName2" id="empName2" size="30" /></td> <td><input type="text" name="note2" id="note2" size="30" /></td> <td><input type="text" name="hours2" id="hours2" size="30" /></td> </tr> </tbody> </table> </form> </body> </html> here is the dosomething.php: <?php $frmSubmitted = $_REQUEST['check_submit']; if (isset($frmSubmitted)) { $message = "data valid and form posted."; $numOfRows = $_REQUEST['numOfRowsSubmit']; $message .= "<br />number of rows submitted: " . $numOfRows; //for($i=1; $i <= $numOfRows; $i++) for($i=1; $i <= 2; $i++) { $nameRow = 'empName' . $i; $noteRow = 'note' . $i; $hoursRow = 'hours' . $i; $message .= "<br />name Row " . $i . " = " . $_REQUEST[$nameRow]; $message .= "<br />note Row " . $i . " = " . $_REQUEST[$noteRow]; $message .= "<br />hours Row " . $i . " = " . $_REQUEST[$hoursRow]; } } else { $message = "form not posted."; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> </head> <body> <!--begin right main information --> <!-- retrieve time sheet information from database --> <table width="100%" height="100%" border="0" cellpadding="5" cellspacing="1"> <tr> <td> <?php echo $message; ?> </td></tr> </table> <!-- end retrive time sheet information --> <!-- end right main information --> </body> </html> thanks for all your kind help!
-
I want to display a php calendar in a monthly view on my page left hand side. What I want from this calendar are: 1. each date is clickable. When it is clicked, the information stored in the database based on this date will be retrived and displayed on the right side of the page. 2. allow user to move backwards and forwards a month at a time in a month view. But by doing this, it shouldn't change any infomration displayed on the right side of the page. I've started the basic coding here. Can somebody give me some hint on how to achieve these functions? Here are mine code: 1. calendarTest.php <?php include ("includes/calendar.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link rel="stylesheet" type="text/css" media="screen" href="css/calendar.css" /> </head> <body> <table width="100%" border="1" cellspacing="0" cellpadding="2"> <tr> <td> <?php // If no month/year set, use current month/year $d = getdate(time()); if ($month == "") { $month = $d["mon"]; } if ($year == "") { $year = $d["year"]; } $cal = new Calendar; echo $cal->getMonthView($month, $year); ?></td> <td>Information will be pulled out from database based on a particular date clicked. </td> </tr> </table> </body> </html> 2. code: calendar.php <? // PHP Calendar Class Version 1.4 (5th March 2001) // // Copyright David Wilkinson 2000 - 2001. All Rights reserved. // // This software may be used, modified and distributed freely // providing this copyright notice remains intact at the head // of the file. // // This software is freeware. The author accepts no liability for // any loss or damages whatsoever incurred directly or indirectly // from the use of this script. The author of this software makes // no claims as to its fitness for any purpose whatsoever. If you // wish to use this software you should first satisfy yourself that // it meets your requirements. // // URL: http://www.cascade.org.uk/software/php/calendar/ // Email: [email protected] // modified by Janet Chen on 10/15/2008 class Calendar { /* Constructor for the Calendar class */ function __construct() { } /* Get the array of strings used to label the days of the week. This array contains seven elements, one for each day of the week. The first entry in this array represents Sunday. */ function getDayNames() { return $this->dayNames; } /* Set the array of strings used to label the days of the week. This array must contain seven elements, one for each day of the week. The first entry in this array represents Sunday. */ function setDayNames($names) { $this->dayNames = $names; } /* Get the array of strings used to label the months of the year. This array contains twelve elements, one for each month of the year. The first entry in this array represents January. */ function getMonthNames() { return $this->monthNames; } /* Set the array of strings used to label the months of the year. This array must contain twelve elements, one for each month of the year. The first entry in this array represents January. */ function setMonthNames($names) { $this->monthNames = $names; } /* Gets the start day of the week. This is the day that appears in the first column of the calendar. Sunday = 0. */ function getStartDay() { return $this->startDay; } /* Sets the start day of the week. This is the day that appears in the first column of the calendar. Sunday = 0. */ function setStartDay($day) { $this->startDay = $day; } /* Gets the start month of the year. This is the month that appears first in the year view. January = 1. */ function getStartMonth() { return $this->startMonth; } /* Sets the start month of the year. This is the month that appears first in the year view. January = 1. */ function setStartMonth($month) { $this->startMonth = $month; } /* Return the URL to link to in order to display a calendar for a given month/year. You must override this method if you want to activate the "forward" and "back" feature of the calendar. Note: If you return an empty string from this function, no navigation link will be displayed. This is the default behaviour. If the calendar is being displayed in "year" view, $month will be set to zero. */ function getCalendarLink($month, $year) { //return ""; //Redisplay the current page, but with some parameters to set the new month and year $s = getenv($_SERVER['SCRIPT_NAME']); return "$s?month=$month&year=$year"; } /* Return the URL to link to for a given date. You must override this method if you want to activate the date linking feature of the calendar. Note: If you return an empty string from this function, no navigation link will be displayed. This is the default behaviour. */ function getDateLink($day, $month, $year) { //return ""; $s = getenv($_SERVER['SCRIPT_NAME']); return "$s?year=$year&month=$month&day=$day"; } /* Return the HTML for the current month */ function getCurrentMonthView() { $d = getdate(time()); return $this->getMonthView($d["mon"], $d["year"]); } /* Return the HTML for the current year */ function getCurrentYearView() { $d = getdate(time()); return $this->getYearView($d["year"]); } /* Return the HTML for a specified month */ function getMonthView($month, $year) { return $this->getMonthHTML($month, $year); } /* Return the HTML for a specified year */ function getYearView($year) { return $this->getYearHTML($year); } /******************************************************************************** The rest are private methods. No user-servicable parts inside. You shouldn't need to call any of these functions directly. *********************************************************************************/ /* Calculate the number of days in a month, taking into account leap years. */ function getDaysInMonth($month, $year) { if ($month < 1 || $month > 12) { return 0; } $d = $this->daysInMonth[$month - 1]; if ($month == 2) { // Check for leap year // Forget the 4000 rule, I doubt I'll be around then... if ($year%4 == 0) { if ($year%100 == 0) { if ($year%400 == 0) { $d = 29; } } else { $d = 29; } } } return $d; } /* Generate the HTML for a given month */ function getMonthHTML($m, $y, $showYear = 1) { $s = ""; $a = $this->adjustDate($m, $y); $month = $a[0]; $year = $a[1]; $daysInMonth = $this->getDaysInMonth($month, $year); $date = getdate(mktime(12, 0, 0, $month, 1, $year)); $first = $date["wday"]; $monthName = $this->monthNames[$month - 1]; $prev = $this->adjustDate($month - 1, $year); $next = $this->adjustDate($month + 1, $year); if ($showYear == 1) { $prevMonth = $this->getCalendarLink($prev[0], $prev[1]); $nextMonth = $this->getCalendarLink($next[0], $next[1]); } else { $prevMonth = ""; $nextMonth = ""; } $header = $monthName . (($showYear > 0) ? " " . $year : ""); $s .= "<table class=\"calendar\">\n"; $s .= "<tr>\n"; $s .= "<td align=\"center\" valign=\"top\">" . (($prevMonth == "") ? " " : "<a href=\"$prevMonth\"><<</a>") . "</td>\n"; $s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\" colspan=\"5\">$header</td>\n"; $s .= "<td align=\"center\" valign=\"top\">" . (($nextMonth == "") ? " " : "<a href=\"$nextMonth\">>></a>") . "</td>\n"; $s .= "</tr>\n"; $s .= "<tr>\n"; $s .= "<td align=\"center\" valign=\"top\" class=\"calendarWeek\">" . $this->dayNames[($this->startDay)%7] . "</td>\n"; $s .= "<td align=\"center\" valign=\"top\" class=\"calendarWeek\">" . $this->dayNames[($this->startDay+1)%7] . "</td>\n"; $s .= "<td align=\"center\" valign=\"top\" class=\"calendarWeek\">" . $this->dayNames[($this->startDay+2)%7] . "</td>\n"; $s .= "<td align=\"center\" valign=\"top\" class=\"calendarWeek\">" . $this->dayNames[($this->startDay+3)%7] . "</td>\n"; $s .= "<td align=\"center\" valign=\"top\" class=\"calendarWeek\">" . $this->dayNames[($this->startDay+4)%7] . "</td>\n"; $s .= "<td align=\"center\" valign=\"top\" class=\"calendarWeek\">" . $this->dayNames[($this->startDay+5)%7] . "</td>\n"; $s .= "<td align=\"center\" valign=\"top\" class=\"calendarWeek\">" . $this->dayNames[($this->startDay+6)%7] . "</td>\n"; $s .= "</tr>\n"; // We need to work out what date to start at so that the first appears in the correct column $d = $this->startDay + 1 - $first; while ($d > 1) { $d -= 7; } // Make sure we know when today is, so that we can use a different CSS style $today = getdate(time()); while ($d <= $daysInMonth) { $s .= "<tr>\n"; for ($i = 0; $i < 7; $i++) { $class = ($year == $today["year"] && $month == $today["mon"] && $d == $today["mday"]) ? "calendarToday" : "calendar"; $s .= "<td class=\"$class\" align=\"right\" valign=\"top\">"; if ($d > 0 && $d <= $daysInMonth) { $link = $this->getDateLink($d, $month, $year); $s .= (($link == "") ? $d : "<span class=\"datelink\"><a href=\"$link\">$d</a></span>"); } else { $s .= " "; } $s .= "</td>\n"; $d++; } $s .= "</tr>\n"; } $s .= "</table>\n"; return $s; } /* Generate the HTML for a given year */ function getYearHTML($year) { $s = ""; $prev = $this->getCalendarLink(0, $year - 1); $next = $this->getCalendarLink(0, $year + 1); $s .= "<table class=\"calendar\" border=\"0\">\n"; $s .= "<tr>"; $s .= "<td align=\"center\" valign=\"top\" align=\"left\">" . (($prev == "") ? " " : "<a href=\"$prev\"><<</a>") . "</td>\n"; $s .= "<td class=\"calendarHeader\" valign=\"top\" align=\"center\">" . (($this->startMonth > 1) ? $year . " - " . ($year + 1) : $year) ."</td>\n"; $s .= "<td align=\"center\" valign=\"top\" align=\"right\">" . (($next == "") ? " " : "<a href=\"$next\">>></a>") . "</td>\n"; $s .= "</tr>\n"; $s .= "<tr>"; $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(0 + $this->startMonth, $year, 0) ."</td>\n"; $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(1 + $this->startMonth, $year, 0) ."</td>\n"; $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(2 + $this->startMonth, $year, 0) ."</td>\n"; $s .= "</tr>\n"; $s .= "<tr>\n"; $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(3 + $this->startMonth, $year, 0) ."</td>\n"; $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(4 + $this->startMonth, $year, 0) ."</td>\n"; $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(5 + $this->startMonth, $year, 0) ."</td>\n"; $s .= "</tr>\n"; $s .= "<tr>\n"; $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(6 + $this->startMonth, $year, 0) ."</td>\n"; $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(7 + $this->startMonth, $year, 0) ."</td>\n"; $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(8 + $this->startMonth, $year, 0) ."</td>\n"; $s .= "</tr>\n"; $s .= "<tr>\n"; $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(9 + $this->startMonth, $year, 0) ."</td>\n"; $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(10 + $this->startMonth, $year, 0) ."</td>\n"; $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(11 + $this->startMonth, $year, 0) ."</td>\n"; $s .= "</tr>\n"; $s .= "</table>\n"; return $s; } /* Adjust dates to allow months > 12 and < 0. Just adjust the years appropriately. e.g. Month 14 of the year 2001 is actually month 2 of year 2002. */ function adjustDate($month, $year) { $a = array(); $a[0] = $month; $a[1] = $year; while ($a[0] > 12) { $a[0] -= 12; $a[1]++; } while ($a[0] <= 0) { $a[0] += 12; $a[1]--; } return $a; } /* The start day of the week. This is the day that appears in the first column of the calendar. Sunday = 0. */ var $startDay = 0; /* The start month of the year. This is the month that appears in the first slot of the calendar in the year view. January = 1. */ var $startMonth = 1; /* The labels to display for the days of the week. The first entry in this array represents Sunday. */ var $dayNames = array("S", "M", "T", "W", "T", "F", "S"); /* The labels to display for the months of the year. The first entry in this array represents January. */ var $monthNames = array("Jan.", "Feb.", "Mar.", "Apr.", "May", "June", "July", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."); /* The number of days in each month. You're unlikely to want to change this... The first entry in this array represents January. */ var $daysInMonth = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); } /* class MyCalendar extends Calendar { function getCalendarLink($month, $year) { //Redisplay the current page, but with some parameters to set the new month and year $s = getenv('SCRIPT_NAME'); return "$s?month=$month&year=$year"; } } */ ?> 3. code: calendar.css @charset "utf-8"; /* CSS Document */ .calendar { border-collapse: collapse; border: 1px solid #03476F; font: normal 11px verdana, arial, helvetica, sans-serif; color: #363636; background: #FFFFCC; /* background-color: #92C428;*/ } .calendarHeader { font-weight: bolder; color: #CC0000; background-color: #FFFFCC; } .calendarWeek { font-weight:bold; color:#666633; background-color: #FFFFCC; } .calendarToday { background-color:#FFCC99; } .datelink A:link {text-decoration: none; color: #363636;} .datelink A:visited {text-decoration: none} .datelink A:active {text-decoration: none} .datelink A:hover {background-color:#E2915F; text-decoration: none; color:#0000FF;} Thanks very much!
-
Yes. I want to pass the server time to javascript, and then advance the time. But I don't know how to pass php time() to javascript and process it. here is what I did: But javascript But javascript Date() function returns is totally different from php time() does. How can I process the information in javascript? Any help? Pretty new to both languages. Thanks!
-
Thanks for the quick reply. However, I found this current time was based on the user's computer clock. What I wanted is reading from server time clock, since different user can modify their computer clock. Any suggestion?
-
I was able to display the current server time on my page, like this: This code is in my topmain.php. And topmain.php is included in the index.php. Once the index.php file is loaded, the time displayed is the time when the page was loaded. Does anyone knows how to display the real time as the clock clicks. Thanks!!!
-
I'm new to PHP/LDAP. And tried to use LDAP bind function:ldap_bind(). The weird thing is if I use anonymous bind, it shows: LDAP bind successful... However, if I give my credentials (my username and password), it always display warning message: Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Inv alid credentials in C:\wamp\virtual\wga\itest2\www\ldapConnect\bindTest.php on line 13 LDAP bind failed... Here is my very simple code: <?php $host = ''; //I provide the IP address of AD controller // using ldap bind $ldaprdn = ''; // ldap rdn or dn $ldappass = ''; // associated password $ldapconn = ldap_connect($host) or die("Could not connect to LDAP server."); if ($ldapconn) { // binding to ldap server $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass); // verify binding if ($ldapbind) { echo "LDAP bind successful...<br />"; } else { echo "LDAP bind failed..."; } } // all done? clean up ldap_close($ldapconn); ?> Can somebody tell me what's wrong? I also noticed when I check my phpinfo(), PHP Version 5.2.5, it shows: LDAP Support: enabled RCS Version: $Id: ldap.c,v 1.161.2.3.2.11 2007/07/17 09:09:42 jani Exp $ Total Links: 0/unlimited API Version: 2004 Vendor name: OpenLDAP Vendor Version: 0 WHY the vendor version is 0? Is than an error? if it is, is it due to the wrong configuration? What's the fix? Does this error caused my LDAP function not working properlly? Thanks, I'm really frustrated now.
-
I would like to know if anyone has configured Open LDAP on Windows XP enviroment. I have WAMP installed on my computer (Apache2.2.8, php5.2.6, MySQL 5.0.51). My boss is asking me to build an intranet site. Here is what should happen: 1. The php application will recognizes who the users are using Active Directory information without having to log in again. 2. Be able to pull employee information from Active Directory (eg, name, department, hire date, etc...) I did some reearch and find that the solution is to use PHP/LDAP. But the OpenLDAP is for Linux/Unix environment. And I have no clue how to make the configuration for my Windows XP. Any help?????? I'm fairly new to PHP, and totally new to LDAP. REALLY RUN OUT OF IDEAS!