RE: [PHP-WIN] Re: PHP generation of <select> fields

From: Date: Tue, 07 May 2002 20:25:01 +0000
Subject: RE: [PHP-WIN] Re: PHP generation of <select> fields
Groups: php.windows 
Request: Send a blank email to php-windows+get-13608@lists.php.net to get a copy of this message
At the beginning of the page, i set start_time $this->start_time = getmicrotime(); // this is somewhere in my page object function getmicrotime() { list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } Then, at the end, i simply subtract: <? $s = $this->getmicrotime() - $this->page_start; ?> Page generated in <?= sprintf("%0.3f", $s); ?> sec(s) It's a neat addition that's a snap to add to any page :) --- Scott Hurring Systems Programmer EAC Corporation ScottH@eac.com Voice: 201-462-2149 Fax: 201-288-1515 > -----Original Message----- > From: Dash McElroy [mailto:Dash@westonefcu.org] > Sent: Friday, May 03, 2002 7:22 PM > To: 'Scott Hurring' > Subject: RE: [PHP-WIN] Re: PHP generation of <select> fields > > > Scott, > > Nice scripts. How did you get the PHP "page generated in x.xx > seconds" on > each page? > > -Dash > > -----Original Message----- > From: Scott Hurring [mailto:scott@eacnet.com] > Sent: Friday, May 03, 2002 1:32 PM > To: Php-Win (E-mail) > Subject: RE: [PHP-WIN] Re: PHP generation of <select> fields > > > If anyone's interested, i've posted up a very simple > HTML class i wrote to handle form elements. > http://furt.com/code/php/html_class/ > > It'll do what you're looking for: > > > $html = new Html(); > > for ($i=0; $i<=12; $i++) > $all_months[ date("m",mktime(0,0,0,$i)) ] = > date("F",mktime(0,0,0,$i)); > > print $html->select('form[months]', $all_months, date("m")); > > > --- > Scott Hurring > Systems Programmer > EAC Corporation > ScottH@eac.com > Voice: 201-462-2149 > Fax: 201-288-1515 > > > -----Original Message----- > > From: Dash McElroy [mailto:Dash@westonefcu.org] > > Sent: Thursday, May 02, 2002 6:45 PM > > To: php-windows@lists.php.net > > Subject: RE: [PHP-WIN] Re: PHP generation of <select> fields > > > > > > It's been a while since I've done a 'for' statement... > > > > Here's my new working code: > > > > <?php > > for ($i=01;$i<=12;$i++) { > > if($i == date("m")) { > > $selected = " selected"; > > } > > else { > > $selected = ""; > > } > > print "<option > > > > value=\"".date("m",mktime(0,0,0,$i))."\"$selected>".date("F",m > > ktime(0,0,0,$i > > ))."</option>\n"; > > } > > ?> > > > > I found that you have to put quotes around the date() > paramaters (like > > date("m") instead of date(m)) or PHP will put an error > message in your > > error.log file in Apache (2.0.35/php4.2.0). Here's the message: > > > > PHP Notice: Use of undefined constant m - assumed 'm' in C:\Program > > Files\Apache Group\Apache2\htdocs\select.php on line 3 > > > > My error log was huge because of this (and the failed first > > attempt of this > > code). > > > > -Dash > > > > -----Original Message----- > > From: George Nicolae [mailto:geomasterweb@hotmail.com] > > Sent: Thursday, May 02, 2002 3:19 PM > > To: php-windows@lists.php.net > > Subject: [PHP-WIN] Re: PHP generation of <select> fields > > > > > > you make two mistakes. let's see the correct code: > > > > for ($i=1;$i<=12;$i++) > > { > > if($i == date(m)) > > //first here ^^^ (must be == not just one "=") > > { > > $selected = " selected"; > > } > > //here is the second: if $selected ="selected" for $i=4 (may) > > $i will be > > remain selected for all month > then may > > //you need the following line to correct this problem. > > else $selected=""; > > print "<option > > value=\"".date(m,mktime(0,0,0,$i))."\"$selected>".date(F,mktim > > e(0,0,0,$i))." > > </option>\n"; > > } > > > > > > -- > > > > > > Best regards, > > George Nicolae > > IT Manager > > ___________________ > > PaginiWeb.com - Professional Web Design > > www.PaginiWeb.com > > > > > > "Dash McElroy" <Dash@westonefcu.org> wrote in message > > news:ABA3F1F1A223D411BE6C006008A6F7E23E6425@MSX1-PTON... > > > I am trying to use PHP to generate and automatically select > > the current > > > month in an HTML Form. Here is the code that flails: > > > > > > for ($i=01;$i<=12;$i++) { > > > if($i = date(m)) { > > > $selected = " selected"; > > > } > > > print "<option > > > > > value=\"".date(m,mktime(0,0,0,$i))."\"$selected>".date(F,mktim > > e(0,0,0,$i))." > > > </option>\n"; > > > } > > > > > > The output is a large amount of April's in the Select > > dropdown box - my > > > machine then goes crazy for a while whilst the hard drive > > chunks like mad. > > > > > > Thanks. > > > > > > -Dash > > > > > > > > -- > > PHP Windows Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > > PHP Windows Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.windows (#13608) next »