Jump to content

ScotDiddle

Members
  • Posts

    204
  • Joined

  • Last visited

    Never

Everything posted by ScotDiddle

  1. Phpnewbie23, Notice the JS : <script type="text/javascript" language="JavaScript" src="javascript/overlib_positioncap.js"></script> This is from an unofficial plugin available here: http://overlib.boughner.us/plugins/positioncap_commands.html Using this plugin, with the DATA or SRC parameters which this plugin supplys, you can now pass a complete HTML or PHP page to overLib... Vis: <script type="text/javascript"> overLibForMetricDisplay = true; <?php switch ($tableName) { ... case 'Hourly Tran Count By SysID' : if (overLibForMetricDisplay) { return overlib('', DATA, 'include/overLibTableName.php?table=hourly_tran_count_by_sysid', WIDTH, 460, HEIGHT, 90, WRAP, FIXX, 120, FIXY, 200, FGCOLOR, '#f0F9F9', BGCOLOR, 'GREEN', NOBORDER, VAUTO, MOUSEOFF); } break; ... } // END Switch ?> </script> Where, 'include/overLibTableName.php' looks like the following: ( Substitute you own overLib('', DATA, 'someFileName.php' ...); parms ) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;charset=UTF-8"> <title> Hourly Tran Count by SysID </title> <link rel="stylesheet" href="../css/UpgfMetrics.css" /> </head> <body> <font color=\#205E75"> <div id="overDiv" style="position: absolute; visibility: hidden; z-index: 1000;"></div> <table border="0"> <?php $overLibTable = $_GET['table']; // Turn on to test format... // $overLibTable = 'hourly_tran_count_by_sysid'; if ( (isset($overLibTable)) && ($overLibTable != NULL) ) { switch($overLibTable) { case 'hourly_tran_count_by_sysid' : $rows = <<<EOR <tr> <td valign="top"> <img src="../images/transactionGraphHomeTabImage.png" > </td> <td valign="top"> Hourly Tran Count by SysID <br /> <br />Line Graph of transaction counts, per choosen SysID(s), for 24 Hours. </td> </tr> EOR; break; case 'tran_response_time_by_sysid' : $rows = <<<EOR <tr> <td valign="top"> <img src="../images/secondaryLineGraph.png" > </td> <td valign="top"> Hourly Tran Response Time By SysID <br /> <br />Line Graph of transaction response averages, per choosen SysID(s), for 24 Hours. <br /><br /> </td> </tr> EOR; break; case 'tran_count_per_hour_by_tranid' : $rows = <<<EOR <tr> <td valign="top"> <img src="../images/transactionGraphHomeTabImage.png" > </td> <td valign="top"> Tran Count per Hour by Tran ID <br /> <br />Line Graph of transaction counts, per choosen Tran ID, for 24 Hours. </td> </tr> EOR; break; case 'hourly_tran_cpu_utilization_by_sysid' : $rows = <<<EOR <tr> <td valign="top"> <img src="../images/not16by16.gif" > </td> <td valign="top"> Hourly Tran CPU Utilization By SysID <br /> <br />Under Construction </td> </tr> EOR; break; case 'tran_count_by_tranid' : $rows = <<<EOR <tr> <td valign="top"> <img src="../images/brownBarIcon.png"> </td> <td valign="top"> Tran Count By TranID <br /> <br /> Bar Graph of individual transaction counts for a specified date, per choosen SysID(s). </td> </tr> EOR; break; case 'tran_response_time_by_tranid' : $rows = <<<EOR <tr> <td valign="top"> <img src="../images/sgBarIcon.png" > </td> <td valign="top"> Tran Response Time By TranID<br><font color="#F6F9F9"> </font> <br /> Bar Graph of individual transaction response time average, for a specified date or date-range. </td> </tr> EOR; break; case 'tran_cpu_utilization_by_tranid' : $rows = <<<EOR <tr> <td valign="top"> <img src="../images/not16by16.gif" > </td> <td valign="top"> Tran CPU Utilization By TranID <br /> <br />Under Construction </td> </tr> EOR; break; default : echo " <img src=\"../images/not16by16.gif\" > \n"; echo "<font color=\"blue\">overLib Table name is invalid ( <font color=\"red\"> $overLibTable </font> )</font><br /> See 'javascript/UpgfDHTMLMenuGenerator.js' around line 1018 <font color=\"blue\">\n"; exit; break; } echo $rows; } else { if (!isset($overLibTable)) { $overLibTable = '*** Not Set ***'; } if ($overLibTable == NULL) { $overLibTable = '*** NULL ***'; } echo " <img src=\"../images/not16by16.gif\" > \n"; echo "<font color=\"blue\">Table name required for overLib display is</font><font color=\"red\"> not set</font/><br /> See 'javascript/UpgfDHTMLMenuGenerator.js' around line 1018 <font color=\"blue\">\n"; exit; } ?> </table> </body> </html> This PHP program and the overLib call produces the green box below the menu drop-down seen in the following image: Ya gotta love overLib !!!! Scot L. Diddle, Richmond VA
  2. Phpnewbie23, The above code was not tested... Here is an HTML page with overLib that I did test... ( change the img src= ... statement back to : src='./images/warning-icon.gif' Scot L. Diddle, Richmond VA <html> <head> <!-- overLib --> <script type="text/javascript" language="JavaScript" src="javascript/overlib.js"></script> <script type="text/javascript" language="JavaScript" src="javascript/overlib_positioncap.js"></script> <script type="text/javascript" language="JavaScript" src="javascript/overlib_centerpopup.js"></script> <script type="text/javascript" language="JavaScript" src="javascript/overlib_followscroll.js"></script> </head> <body> <?php echo "<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000;\"></div> \n"; $remarks = "Backup Completed Partially."; if ($remarks == "Backup Completed Partially.") { echo "<td bgcolor=$row_color align=center><small><img src='images/xyz.jpg' align='center'<a href=\"javascript:void(0);\" onmouseover=\"return overlib('$remarks',STICKY, MOUSEOFF);\"> \n"; } ?> </body> </html>
  3. Phpnewbie23, Like this: <?php if ($remarks == "Backup Completed Partially."); echo "<td bgcolor=$row_color align=center><small><img src='./images/warning-icon.gif' align='center'<a href=\"javascript:void(0);\" onmouseover=\"return overlib('$remarks',STICKY, MOUSEOFF);\"> \n"; ?> or, a little fancier : <?php if ($remarks == "Backup Completed Partially.") { echo "<td bgcolor=$row_color align=center><small><img src='./images/warning-icon.gif' align='center'<a href=\"javascript:void(0);\" onmouseover=\"return overlib('$remarks', WIDTH, 166, HEIGHT, 10, WRAP, OFFSETX, 35, OFFSETY, 15, FGCOLOR, '#F6F9F9', BGCOLOR, 'GREEN', NOBORDER, VAUTO);\"> \n"; } ?> Also, don't forget to include the requisite overLib div statment just after the <body> tag. <body> <?php echo "<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000;\"></div> \n"; ?> NOTE: I always use opening / closing brackets for IF statments, even if there is only one staement exeuted... It makes you intent abundantly clear, and when you have to change something in the future related to your IF statement ( AND YOU WILL ) doing so will keep you out of trouble. Let us know if the new examples work... Scot L. Diddle, Richmond VA
  4. Phpnewbie23, The best there is: http://www.bosrup.com/web/overlib/ Fully customizable.... Scot L. Diddle, Richmond VA
  5. eva21, Take a look here... http://www.webmasterworld.com/forum88/2100.htm It explains how to use the JS new image() function to pass JS parms to PHP. Scot L. Diddle
  6. apulmca, You can use the optional parameters... See here: http://doc-typo3.ameos.com/3.7.0/classFPDF.html#c883bc75c65959ce84adaa102eb22da9 $sourceImage = 'images/MyJpg.jpg' $c1 = 20; $c2 = 40; $h = 172; $pdf->Image($sourceImage,$c1,$c2,$h); Scot L. Diddle, Richmond VA
  7. coolphpdude, The following JS program isn't free ( $29 ), but it sure is worth the money. http://www.softcomplex.com/products/tigra_calendar_pro/ Scot L. Diddle, Richmond VA
  8. thorpe, In my code window, click in the scroll bar white area 5 times, and you will come to the following... It is internal to the "function mail_attachment( ..." Scot <?php if (mail($mailto, $subject, "", $header)) { return TRUE; } else { return FALSE; } ?>
  9. thorpe, A little lenghty, but here it is... Thanks for looking at it. Scot L. Diddle, Richmond VA <?php $myCapturedOutput = $smarty->fetch('HAZSPILL.html.tpl'); function mail_attachment($ExcelPath, $ExcelFilename, $CSVPath, $CSVFilename, $mailto, $from_mail, $from_name, $replyto, $subject, $message) { // This bad boy came from : http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php $uid = md5(uniqid(time())); if ($ExcelPath != "") { $ExcelFile = $ExcelPath . $ExcelFilename; $ExcelFile_size = filesize($ExcelFile); $ExcelHandle = fopen($ExcelFile, "r"); $ExcelContent = fread($ExcelHandle, $ExcelFile_size); fclose($ExcelHandle); $ExcelContent = chunk_split(base64_encode($ExcelContent)); // $CSVFile = $CSVPath . $CSVFilename; // $CSVFile_size = filesize($CSVFile); // $CSVHandle = fopen($CSVFile, "r"); // $CSVContent = fread($CSVHandle, $CSVFile_size); // fclose($CSVHandle); // // $CSVContent = chunk_split(base64_encode($CSVContent)); // // $name = basename($ExcelFile); } $header = "From: ".$from_name." <".$from_mail.">\r\n"; $header .= "Reply-To: ".$replyto."\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=".$uid."\r\n\r\n"; $header .= "This is a multi-part message in MIME format.\r\n \n"; if ($ExcelPath != "") { // Allow Attachments //$header .= "MIME-Version: 1.0\r\n"; //$header .= "Content-Type: multipart/mixed; boundary=".$uid."\r\n\r\n"; //$header .= "This is a multi-part message in MIME format.\r\n \n"; // Here is the Excel Attachment $header .= "--".$uid."\r\n"; $header .= "Content-Type: application/octet-stream; name=".$ExcelFilename."\r\n"; // use diff. types here $header .= "Content-Transfer-Encoding: base64\r\n"; $header .= "Content-Disposition: attachment; filename=".$ExcelFilename."\r\n\r\n"; $header .= $ExcelContent."\r\n\r\n"; // Here is the CSV Attachment // Defunct 10/20/2008 // Tab and Double-quote delimited file worked better in MS Access... // $header .= "--".$uid."\r\n"; // $header .= "Content-Type: application/text; name=".$CSVFilename."\r\n"; // use diff. types here // $header .= "Content-Transfer-Encoding: base64\r\n"; // $header .= "Content-Disposition: attachment; filename=".$CSVFilename."\r\n\r\n"; // $header .= $CSVContent."\r\n\r\n"; } // Here is the body $header .= "--".$uid."\r\n"; $header .= "Content-type:text/html; charset=iso-8859-1\r\n"; $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $header .= $message."\r\n\r\n"; $header .= "--".$uid."\r\n"; if (mail($mailto, $subject, "", $header)) { return TRUE; } else { return FALSE; } } // $hazspillXLS = 'Hazspill.Test.csv'; // Was '.xls' 10/20/2008 // $hazspillCSV = 'Hazspill.Test.csv'; // Defunct ... Double-quote delimited files works // better as csv than tab delimited file // how to use $userEmailString = $_SESSION['POST']['userSuppliedEmailAddresses']; $userEmailStringPieces = array(); $commaPresent = stristr($userEmailString, ','); if ($commaPresent) { $userEmailStringPieces = explode(',', $userEmailString); } else { $userEmailStringPieces = explode(' ', $userEmailString); } if (is_array($userEmailStringPieces)) { foreach($userEmailStringPieces as $trimCandidateIn) { if ($trimCandidateIn != '' && $trimCandidateIn != ' ') { $trimCandidateOut[] = trim($trimCandidateIn); } } } else { $trimCandidateOut = $userEmailString; } $userEmailStringPieces = $trimCandidateOut; if (is_array($userEmailStringPieces)) { $uniqueEmailAddresses = array_unique($userEmailStringPieces); $emailAddr = array(); foreach ($uniqueEmailAddresses as $emailCandidate) { $isFM = stristr($emailCandidate, 'FormsMaster'); if (!$isFM) { $emailCandidateLen = strlen($emailCandidate); if ($emailCandidateLen != 0) { $emailAddr[] = $emailCandidate; } } } $uniqueEmailAddresses = $emailAddr; $recipients = implode(', ', $uniqueEmailAddresses); } else { $recipients = ''; } // if ($ExcelPath != "") { // $recipients = 'WF_HAZSPILL@upsfreight.com, ScotDiddle@upsfreight.com, ' . $recipients; // } // else { // $recipients = 'ScotDiddle@upsfreight.com, ' . $recipients; // } // $PRONumberString = $_SESSION['POST']['HZ_PRONumbersTextArea']; $PRONumberString = $_SESSION['POST']['HZ_PRONumber']; $PRONumberString = trim($PRONumberString); $PRONumberStringPieces = explode(' ', $PRONumberString); $countOfPRONumbers = count($PRONumberStringPieces); if ($countOfPRONumbers > 1) { $proLiteral = 'PROs'; } else { $proLiteral = 'PRO'; } // $myCapturedOutput is tacked onto the END of $message... if ($recipients != '') { $message = '<br /><font color="red">***</font> <font color="blue">Sent under separate cover to: " ' . $recipients . ' " <font color="red">***</font></font><br />' . $myCapturedOutput; } else { $message = '<br /><font color="red">***</font> <font color="blue">No additional recipients specified for this form <font color="red">***</font></font><br />' . $myCapturedOutput; } $ExcelPath = "UPGFData/Excel/Hazspill/"; $ExcelFile = $_SESSION['HZ_ExcelFileAttachmentName']; // $CSVPath = "UPGFData/CSV/Hazspill/"; // Defunct 10/20/2008 // $CSVFile = $_SESSION['HZ_CSVFileAttachmentName']; // Defunct 10/20/2008 $CSVPath = ''; $CSVFile = ''; $name = "HAZSPILL"; $from = "WebForms@lpismi01.com"; $replyto = ""; $subject = "$proLiteral " . $PRONumberString; if ($_SESSION['WriteFiles']) { $recipient = 'WF_HAZSPILL@upsfreight.com, '; } else { $recipient = 'ScotDiddle@upsfreight.com, '; } $recipientMail1 = $recipient; $mailRC1 = mail_attachment($ExcelPath, $ExcelFile, $CSVPath, $CSVFile, $recipient, $from, $name, $replyto, $subject, $message); $ExcelPath = ""; $ExcelFile = ''; $CSVPath = ""; $CSVFile = ''; $name = "HAZSPILL"; $from = "WebForms@lpismi01.com"; $replyto = ""; $subject = "$proLiteral " . $PRONumberString; $recipient = $recipients; $recipientMail2 = $recipient; // $message = $myCapturedOutput; $message = '<br /><font color="red">***</font> <font color="blue">Sent under separate cover to: " WF_HAZSPILL@upsfreight.com " <font color="red">***</font></font><br />' . $myCapturedOutput; if ($recipient != '') { $mailRC2 = mail_attachment($ExcelPath, $ExcelFile, $CSVPath, $CSVFile, $recipient, $from, $name, $replyto, $subject, $message); } echo "<html> \n"; echo "<body onLoad='javascript:scroll(0,0);'> \n "; if ($mailRC1) { echo "The HAZSPILL form has been sent to: <br /><br /><ul>\"WF_HAZSPILL@upsfreight.com\"</ul><br /></br /> \n "; } else { echo "The HAZSPILL form has NOT been sent to: <br /><br /><ul>\"WF_HAZSPILL@upsfreight.com\"</ul><br /><h4><font color=\"red\">Please inform the Help Desk about this error...</font></h4> \n"; } if ($recipients != '') { if ($mailRC2) { echo "The HAZSPILL form has been sent to: <br /><br /><ul>$recipients</ul><br /></br /> \n "; } else { echo "The HAZSPILL form has NOT been sent to: <br /><br /><ul>$recipients</ul><br /></br /><h4><font color=\"red\">Please inform the Help Desk about this error...</font></h4> \n"; } } echo "Click <a href='javascript: void(0);' onClick='goBack();' title='Click Here To Return to Webforms'>here </a> to return to WebForms...\n "; unset($_SESSION['POST']); /** * * "So long, and thanks for all of the fish" * */ ?>
  10. Gentlefolk, When using the PHP mail function with Apache 2.2, the generated email shows the message indicated in the title of this post... Above the message I find the text I coded as the "from" var. Any ideas on how to suppress / change / delete said message ? Thanks, Scot L. Diddle, Richmond VA
  11. mattphilips , Also, the home (dir) of any file you want to include must be specified in the php.ini " include_path " directive. I suspect that if you coded error_reporting['E_ALL']; at the beginning of your script, it will tell you that the file can't be found. My ini include_path statement looks like this : include_path=".:/usr/local/Zend/Core/share/pear:/usr/local/Zend/www/dev:/usr/local/Zend/www/dev/include:/usr/local/Zend/www/dev/font:/usr/local/Zend/www/dev/include/lang:/usr/local/Zend/www/dev/classes:/usr/local/Zend/www/dev/javascript:/usr/local/Zend/www/dev/library:/usr/local/Zend/www/dev/WebSVN:/usr/local/Zend/www/dev/WebSVN/languages:/usr/local/Zend/www/dev/smarty:/usr/local/Zend/www/dev/smarty/libs:/usr/local/Zend/www/dev/smarty/templates:/usr/local/Zend/www/dev/smarty/template_c:" Scot L. Diddle, Richmond VA
  12. richardjh, How are $catname, $cat, $val2 and $val4 being sent and intercepted. $_SESSION['whatEver'] type vars are EXACTALLY like ALL other PHP vars; they take on the value of the var (or constant) assigned to it. Check the $_GET and / or $_POST form values each time a user submits the form ( either with a " foreach() {echo $_GET / $_POST " or a " print_r() function " as soon as the values are supposed to be available, and make sure they are all there and within the range of values you are expecting. Scot L. Diddle, Richmond VA
  13. hookit You're missing a closing quote here: echo 'NO RESULTS FOUND; Scot L. Diddle, Richmond VA
  14. Blade280891, PHP is not a windows service, it is an Apache Task. The two services WAMP shows are Apache and MySQL. Use the WAMP drilldown to review the Apache error log... ( Click on the WAMP speedometer, then select log files and look at the Apache Error Log and the PHP Error Log. They may point you in the right direction. ) ( This is pre-supposing you are using http://www.wampserver.com/en ... If you aren't, go get it quick and leave the "roll-your-own" behind. )
  15. fj1200, Why not use session data ? Scot To the top of your script, Add: <?php $serverHasSessionSupportEnabled = ini_get('session.auto_start'); if (!$serverHasSessionSupportEnabled) { $sessionSupport = session_start(); if (!$sessionSupport) { echo "You will have to compile you PHP envionment with Session Support before using this script. <br /><br > "; echo "So Long, and thanks for all the fish... <br /><br > <ul><ul><h2> </h2> \n"; exit(); } } ?> Then, when you first get the datapoints you want to graph, do: <?php $_SESSION['graphPair'] = array(); // array( X-axis Value, Y-axis Value) $yIDX = 0; // For Example: $xAxisFromDB = range(1,12); $yAxisFromDB = array(0,3,5,3,2,6,11,12,'',7,7, 15); foreach($xAxisFromDB as $xIDX => $x) { $_SESSION['graphPair'][] = array($x, $yAxisFromDB[$yIDX]); $yIDX++; } // Then later, ( even many scripts / html pages later ) // access the data point array like this : $myGraphData = $_SESSION['graphPair']; $xForGraph = array(); $yForGraph = array(); foreach ($myGraphData as $pairIDX => $currentDataPair) { /** * * Use data in $currentDataPair to generate graph... * */ foreach($currentDataPair as $scaleIDX => $scalePoint) { switch($scaleIDX) { case 0 : $xForGraph[] = $scalePoint; break; case 1 : $yForGraph[] = $scalePoint; break; } } } // See the results $display = TRUE; if ($display) { require_once('include/debugFunctions.php'); echo "<font color=\"#205E75\"> \n"; printArray($xForGraph, '$xForGraph'); printArray($yForGraph, '$yForGraph'); echo "<font color=\"black\"> \n"; } ?> This will produce this: Name : $xForGraph Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 [9] => 10 [10] => 11 [11] => 12 ) Name : $yForGraph Array ( [0] => 0 [1] => 3 [2] => 5 [3] => 3 [4] => 2 [5] => 6 [6] => 11 [7] => 12 [8] => [9] => 7 [10] => 7 [11] => 15 ) If your printArray() function performs similar to this: <?php #-- Assignment : List arbitary number of name in an HTML table function listNames() { GLOBAL $table; $table = "<table border=\"1\"> \n"; if (func_num_args() > 0) { $numOfArgs = func_num_args(); for ($i=0; $i < $numOfArgs; $i++) { $table .= " <tr> \n"; $table .= " <td> \n"; $table .= func_get_arg($i); $table .= " </td> \n"; $table .= " </tr> \n"; } } else { echo "No Args Passed" . " <br /> \n"; } $table .= "</table> \n"; return $table; } #-- END Assignment : List arbitary number of name in an HTML table # -- printArray : List members in a array -- # function printArray($arrayName, $name = false) { if ($name) { echo "Name : $name" . " <br /> \n"; } if (!is_array($arrayName)) { $saveArray = $arrayName; $arrayName = 'Not An Array'; $possibleString = TRUE; } if (empty($arrayName)) { $arrayName = 'Array Contain No Data'; } echo "<font color=\"#205E75\"> \n"; echo "<pre> \n"; print_r($arrayName); echo "</pre> \n"; echo "</font> \n"; if ($possibleString == TRUE) { $string = $saveArray; if ($string == NULL) { $string = 'Null String'; } echo "<font color=\"#205E75\"> \n"; echo " <br /> <br /> \n"; echo '$array as string: ' . $string . "<br /> <br /> \n"; echo " <br /> <br /> \n"; echo "</font> \n"; } } function printArrayVarDump($arrayName, $name = false) { if ($name) { echo "Name : $name" . " <br /> \n"; } echo "<pre> \n"; var_dump($arrayName); echo "</pre> \n"; if ($possibleString == TRUE) { $string = $arrayName; if ($string == NULL) { $string = 'Null String'; } echo '$array as string: ' . $string . "<br /> <br /> \n"; } // echo " <br /> <br /> \n"; } function arrayPrint($arrayName, $name = false) { printArray($arrayName, $name = false); } ?>
  16. lill77, It should be modified for your environment, then replace your table logic with your modified version... What I think you are trying to do is to create a new row after x number of records ( columns ? ) have been written. In my example, a new row is written after every 3 data points... : Whenever " $IDX % 3 " has the result = 0, then it is time to create a new row ( close current "<tr> " with </tr> then start a new row with <tr>... after ever third <td>value</td> pair has been created. Change 3 to 4 and you will get four items on each row before a new row is created.... (and so on...) The following : <?php $t1 = 0 % 3; $t2 = 1 % 3; $t3 = 2 % 3; $t4 = 3 % 3; echo "\$t1 = 0 % 3; :: " . $t1 . "<br /> <br /> \n"; echo "\$t2 = 1 % 3; :: " . $t2 . "<br /> <br /> \n"; echo "\$t3 = 2 % 3; :: " . $t3 . "<br /> <br /> \n"; echo "\$t4 = 3 % 3; :: " . $t4 . "<br /> <br /> \n"; exit; ?> Produces: $t1 = 0 % 3; :: 0 $t2 = 1 % 3; :: 1 $t3 = 2 % 3; :: 2 $t4 = 3 % 3; :: 0 Replace my : " foreach($somePHPArray as $IDX => $arrayItemValue) { " statement with your : " while($row = mysql_fetch_array($result)) { " Then, replace my table statements with your modifed version which has the new modulo logic. Hope this helps. Scot
  17. lill77, You will want tro try using the modulo result from the '%' operator. Run the following to see the desired effect. It is generic, but should set you on the right path.... Scot L. Diddle, Richmond VA <?php /* Output: row 1 1 2 3 row 2 4 5 6 row 3 7 8 9 row 4 10 11 12 */ $somePHPArray = array(); $somePHPArray = range(1,12); $rowCount = 1; echo "\t<table border =\"1\" width=\"210\" height=\"150\" cellpadding=\"0\" cellspacing=\"0\" style=\"font-size:11px; font-family:Verdana; margin:5px;\">\r\n \n"; foreach($somePHPArray as $IDX => $arrayItemValue) { $modulo = $IDX % 3; if ($modulo === 0) { // Only 3 items per row ( besides the "Row Count" Identifier ) if ($IDX > 0) { // don't write closeing </tr> on first pass... echo "\t\t</tr> \n"; } echo "\t\t<tr> \n"; echo "\t\t\t<td style=\"padding: 5,5,5,5;\"> \n"; echo "\t\t\t\trow " . $rowCount . " \n"; // Once per row $rowCount++; } echo "\t\t\t<td style=\"padding: 5,5,5,5;\"> \n"; echo "\t\t\t\t$arrayItemValue \n"; echo "\t\t\t</td> \n"; } echo "\t</table> "; ?>
  18. phpserver, The method you are describing uses the $_GET PHP variable... Google 'php $_get variable' for numerous examples on how to implement. Scot L. Diddle, Richmond VA
  19. djcrisp22, The comments in my re-write of your index2.php file should point you in the right direction... I tested the following code, and it works, but it is not without risk. The problem is with how you are determining which file is next using the "while()" function. If your folder has save.0, save.1 and save.2 etc, it will write the next file in line. But if your folder has save.0, save.2, save.3, it will write save.1, which is not what I think you want. You should find a better way of determining what files are currently in your folder. Good luck. Scot L. Diddle, Richmond VA index2.php: <?php /** * * Grab the users input... * */ $username = $_POST['username']; $password = $_POST['password']; $email = $_POST['email']; // Set the path to where we want to save our new file $path = $_SERVER['DOCUMENT_ROOT'] . "/misc"; /** * * In /misc/ we have: * * save.0 * save.1 * save.2 * */ $fnum = 0; $filename = "save." . $fnum; while (file_exists($path . '/' . $filename)) { $fnum++; $filename = "save.".$fnum; } // Upon exit from while(... $fnum now == 4 // Set up new file name: $filename = $path . '/' . "save." . $fnum; $contentToWrite = $username . ',' . $password . ',' . $email; $handle = fopen($filename, "w"); $result = fwrite($handle,$contentToWrite); if($result) { echo "Successful Write for new file: $filename"; } else { echo "Write Failed for: $filename"; } fclose($handle); ?>
  20. arn_php, Why not try a javascript solution... I use the very inexpensive, and very feature rich, Tigra Calander Pro... Here is the web site: http://www.softcomplex.com/products/tigra_calendar_pro/ Scot L. Diddle, Richmond VA
  21. AV1611, I wrapped <html> tags around your code and it worked without error on IE7 and Firefox 3.0.3; Scot L. Diddle. Richmond VA <html> <body> <p class="display_only" style="text-align: center;"> <script type="text/javascript" language="Javascript"> // This Script puts a Print Screen Button on the page function printit(){ if (window.print) { alert('Hi Mom'); window.print() ; } else { var WebBrowser = '<object id="WebBrowser1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>'; document.body.insertAdjacentHTML('beforeEnd', WebBrowser); WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = "; } } </script> <script type="text/javascript" language="Javascript"> var NS = (navigator.appName == "Netscape"); var VERSION = parseInt(navigator.appVersion); alert(VERSION); if (VERSION > 3) { document.write('<form><input type="button" value="Print this Page" name="Print" onClick="printit()"></form>'); } </script> </p> </body> </html>
  22. Hi Folks, The excellent autoTab script from: From: http://javascript.internet.com/forms/auto-tab.htm works great, and is a time-saver for my users... This script sets focus to then next field when the maxlenth of the current field is hit by the user. I had to alter the script because some of the "next" fields may "still" be disabled because of the value entered for the "current" field. I found out how to bypass disabled fields from Google, and they all have the same basic format as my code posted below. My question, as seen in the code comments, is why does one need to worry about the form length and modulo ? modulo = inputIDXPlus6 % inputFormLength; (See below for full snippet...) Still trying to learn JS. Thanks for any input. Scot L. Diddle, Richmond VA if (input.id != 'HZ_CostGT500YN') { input.form[(getIndex(input)+1) % input.form.length].focus(); // Focus = current field + 1... } if (input.id == 'HZ_CostGT500YN') { if (mandatoryCostGT500) { input.form[(getIndex(input)+1) % input.form.length].focus(); // Focus = current field + 1... } else { // This meas getIndex(input)+1, +2, +3, +4 and +5 are disabled. // So, to avoid a javascript error, we need to bypass the disabled fields... input.form[(getIndex(input)+6) % input.form.length].focus(); /* Here's how it works... inputIDX = getIndex(input); alert('IDX ' + inputIDX); // 92 inputIDXPlus6 = getIndex(input)+6 alert('IDX + 6 ' + inputIDXPlus6); // 98 inputFormLength = input.form.length; alert('inputFormLength ' + inputFormLength); // 126 modulo = inputIDXPlus6 % inputFormLength; alert('modulo ' + modulo); // 98 formIDX = input.form[modulo]; alert('formIDX ' + formIDX) // object formID = formIDX.id alert('formID ' + formID); // HZ_PersonInjuryYN // Why the modulo? Why not use inputIDXPlus6? // // I tried it and with this example it worked... // // // This will also work: // // document.HZForm.HZ_PersonInjuryYN.focus(); */ } }
  23. tstout2, If you set $success = mail($ToEmail,$ToSubject,$Message, $headers); and the value of $success is false, take a look at this thread... http://www.phpfreaks.com/forums/index.php/topic,214908.0.html By following the instructions and links therein, I got my mail function to work. Good Luck. Scot
  24. samona, Here's what I use... Hope it helps... I just ran it as a stand-alone script and it worked as I expectd... Change the literals, filenames, and path names to match your environment, and it should work... Scot L. Diddle, Richmond... <?php function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) { // This bad boy came from : http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php $file = $path.$filename; $file_size = filesize($file); $handle = fopen($file, "r"); $content = fread($handle, $file_size); fclose($handle); $content = chunk_split(base64_encode($content)); $uid = md5(uniqid(time())); $name = basename($file); $header = "From: ".$from_name." <".$from_mail.">\r\n"; $header .= "Reply-To: ".$replyto."\r\n"; // Allow Attachments $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=".$uid."\r\n\r\n"; $header .= "This is a multi-part message in MIME format.\r\n \n"; // Here is the Attachment $header .= "--".$uid."\r\n"; $header .= "Content-Type: application/octet-stream; name=".$filename."\r\n"; // use diff. types here $header .= "Content-Transfer-Encoding: base64\r\n"; $header .= "Content-Disposition: attachment; filename=".$filename."\r\n\r\n"; $header .= $content."\r\n\r\n"; // Here is the body $header .= "--".$uid."\r\n"; $header .= "Content-type:text/html; charset=iso-8859-1\r\n"; $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $header .= $message."\r\n\r\n"; $header .= "--".$uid."\r\n"; if (mail($mailto, $subject, "", $header)) { return TRUE; } else { return FALSE; } } // how to use $userEmailString = $_SESSION['POST']['userSuppliedEmailAddresses']; $userEmailStringPieces = array(); $userEmailStringPieces = explode(',', $userEmailString); $trimCandidateOut = array(); foreach($userEmailStringPieces as $trimCandidateIn) { if ($trimCandidateIn != '' && $trimCandidateIn != ' ') { $trimCandidateOut[] = trim($trimCandidateIn); } } $userEmailStringPieces = $trimCandidateOut; $uniqueEmailAddresses = array_unique($userEmailStringPieces); $recipients = implode(', ', $uniqueEmailAddresses); $recipients = 'WebFormUSer@xyzCompany.com, ' . $recipients; $controlNumberString = $_SESSION['POST']['HZ_controlNumbersTextArea']; $controlNumberStringPieces = explode(' ', $controlNumberString); $countOfcontrolNumbers = count($controlNumberStringPieces); if ($countOfcontrolNumbers > 1) { $controlLiteral = 'Controls'; } else { $controlLiteral = 'Control'; } $controlNumberOut = array(); if (is_array($controlNumberStringPieces)) { foreach ($controlNumberStringPieces as $controlNumberStringCandidate) { $controlNumberOutCandidate = trim($controlNumberStringCandidate); $commaPresent = stristr($controlNumberOutCandidate, ','); if (!$commaPresent) { $controlNumberOutCandidate .= ', '; } else { $controlNumberOutCandidate .= ' '; } $controlNumberOut[] = trim($controlNumberOutCandidate); } } else { $controlNumberOut[] = trim($controlNumberString); } // END if (is_array($controlNumberStringPieces)) { $controlNumberString = implode(' ', $controlNumberOut); // Eliminate the trailing comma $lencontrolNumberString = strlen($controlNumberString); $last = $lencontrolNumberString - 1; $controlNumberString = substr($controlNumberString,0,$last); // $xlsFile = 'Transaction_Count_by_SysID_e6k71ak5p1ll1u3lk0c74c3ub6.xls'; $file = $xlsFile; $file = 'someValidFileName.xls Goes Here'; $file = 'Transaction_Count_by_SysID_e6k71ak5p1ll1u3lk0c74c3ub6.xls'; $path = 'someValidFilePath Goes Here'; $path = "Excel/Data/"; $name = "From Name Litteral Here"; $from = "UserName@xyzCompany.com"; $replyto = ""; $subject = "$controlLiteral " . $controlNumberString; $recipient = $recipients; $recipient = 'ScotDiddle@xyzCompany.com'; // $message = $myCapturedOutput; // From Smarty processing... $message = '<br /> Hi Mom <br />' ; $mailRC = mail_attachment($file, $path, $recipient, $from, $name, $replyto, $subject, $message); if ($mailRC) { echo "The 'Form Name Goes Here' form has been sent to: <br /><br /><ul>$recipient</ul><br /></br /> \n "; } else { echo "The 'Form Name Goes Here' form has NOT been sent to: <br /><br /><ul>$recipient</ul><br /></br /> "; $error = "The 'Form Name Goes Here' form has NOT been sent to: <br /><br /><ul>$to</ul><br /></br />"; $error .= " Please report this error to the IS Helpdesk. Ask for WebForms help for form: \"'Form Name Goes Here' \"<br /><br> \n"; $error .= " Report that Email delivery failed! <br /><br>"; echo $error; } echo "Click <a href='javascript: void(0);' onClick='javascript:/* goBack(); */' title='Click Here To Return to Webforms'>here </a> to return to WebForms...\n "; ?>
  25. cjbeck71081, It's a matter of escaping those chars that will be present on the newly created php file. The following example is a sub-set from a working script... I couldn't wrap it in [ code ] / [ /code ] elements because this parser complained about the opening single-quotes before the closing $PHPCode[] = '?>' . " \n"; statements.. Hope this helps. Scot L. Diddle, Richmond VA <?php /** * * Define where to place our newly defined HZForm.php file... * * This is the form the user fill out, then submits for Smarty processing, and * subsequent email processing. * */ $HZForm_dir = $_SERVER['DOCUMENT_ROOT']; // Which form is the user dealing with ? $HZForm_FileName = 'HZForm.php'; $HZFormFile = $HZForm_dir . '/' . $HZForm_FileName; if (file_exists($HZFormFile)) { // Get rid of any previous HZForm.php File... It may be out of date. $deleteResults = unlink($HZFormFile); if (!$deleteResults) { $error = " ERROR: Could not delete previous version of HZForm.php file.<br /><br>"; $error .= " Please report this error to the IS Helpdesk. Ask for WebForms help for form: \"HAZSPILL\"<br /><br>"; echo $error; exit; } } /** * * Tack on those items that Smarty processing complains about * */ $debug1 = FALSE; // Display $_SESSION['POST'] vars... $debug2 = TRUE; // Revert to in-line JS for debugging. $PHPCode = array(); $PHPCode[] = '<?php' . "\n"; $PHPCode[] = "\n"; $PHPCode[] = "\n\t\$currentProgram = \$_SERVER['PHP_SELF']; \n"; $PHPCode[] = "\n"; $PHPCode[] = "\n\t\$currentProgramPieces = explode('/', \$currentProgram); \n"; $PHPCode[] = "\n"; $PHPCode[] = "\n\t\$_PHPSELF = \$currentProgramPieces[1]; \n"; $PHPCode[] = "\n"; $PHPCode[] = "\tif (!empty(\$_POST)) {" . "\n"; $PHPCode[] = "\t\t\$_SESSION['POST'] = array(); \n"; $PHPCode[] = "\t\tforeach(\$_POST as \$IDX=> \$DBCandidate) { \n"; $PHPCode[] = "\t\t\t\$_SESSION['POST'][\$IDX] = \$DBCandidate; \n"; $PHPCode[] = "\t\t}" . "\n"; if ($debug1) { // Just above... $PHPCode[] = "\t\t require_once('include/debugFunctions.php');" . "\n"; $PHPCode[] = "\t\t printArray(\$_POST, '\$_POST');" . "\n"; $PHPCode[] = "\t\t printArray(\$_SESSION['POST'], 'POST');" . "\n"; $PHPCode[] = "\n"; $PHPCode[] = "\t\t exit();" . "\n"; } $PHPCode[] = "\n"; $PHPCode[] = "\t\trequire('include/loadHZDB.php'); \n "; $PHPCode[] = "\n"; $PHPCode[] = "\t // exit(); \n"; $PHPCode[] = "\theader('Location: HZSmartyCall.php'); \n "; $PHPCode[] = "\texit(); \n"; $PHPCode[] = "\n"; $PHPCode[] = "\t}" . "\n"; $PHPCode[] = '?>' . " \n"; $headItems = array(); if ($debug2) { // Just above... $PHPCode[] = '<?php' . "\n"; $PHPCode[] = "\techo \"<script type='text/javascript'> \n\"; \n"; $PHPCode[] = "\n"; $PHPCode[] = "\trequire('javascript/HZScripts.js'); \n" . "\n"; $PHPCode[] = "\n"; $PHPCode[] = "\techo \"</script> \n\"; " . "\n"; $PHPCode[] = '?>' . " \n"; } else { $headItems[] = "\t <script type=\"text/javascript\" language=\"JavaScript\" src=\"javascript/HZScripts.js\"></script> \n"; } $headItems[] = "\t<link href=\"css/WebForms.css\" rel=\"stylesheet\" type=\"text/css\" ></link> \n"; $currentFormLines = $_SESSION['hzOut']; $hzLine = array(); $lineOut = 0; $next = FALSE; foreach($PHPCode as $PHPCodeIn) { $hzLine[$lineOut] = $PHPCodeIn; $lineOut++; } foreach($currentFormLines as $hzLineIn) { $stristrResult = stristr($hzLineIn, '<title>'); if ($next) { $next = FALSE; foreach($headItems as $headItemsIn) { $hzLine[$lineOut] = $headItemsIn; $lineOut++; } } else { if ($stristrResult) { $next = 'TRUE'; } $hzLine[$lineOut] = $hzLineIn; $lineOut++; } } $lines = count($hzLine); $fh = fopen($HZFormFile, 'w'); if (!$fh) { echo "ERROR: Could not write the HAZSPILL User Form... Please report this error to the HelpDesk."; exit; } for ($i=0; $i < $lines; $i++) { $stristrQuery = stristr($hzLine[$i], '<textarea'); if (!$stristrQuery) { $hzLine[$i] .= "\n"; } $success = fwrite($fh, $hzLine[$i]); if (!$success) { $errorOccured = TRUE; } } if (!$errorOccured) { // Now that we have written out the form, show it to the user. header('Location: ' . $HZForm_FileName ); exit; } else { $error = " ERROR: Could not write new version of \$_SESSION['hzOut'].php file.<br /><br>"; $error .= " Please report this error to the IS Helpdesk. Ask for WebForms help for form: \"HAZSPILL\"<br /><br>"; echo $error; exit; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.