Jump to content

Awanka

Members
  • Posts

    26
  • Joined

  • Last visited

    Never

Everything posted by Awanka

  1. I can't use a direct http:// link. I run into access issues. Access is only allowed through the resources virtual directory. My question basically is what kind of pathnames can src= accept that file functions like file() cannot. what's the difference between the sort of pathnames the two use. I think it's probably something wierd like the pathname has to end with a "/".
  2. The following line: $fcontents = file("/resources/weekly_highlights/HighlightsList.txt"); throws the following error: Warning: file(/resources/weekly_highlights/HighlightsList.txt) [function.file]: failed to open stream: No such file or directory in C:\APPS_DEV\RM\Highlights.php on line 25 however the following works: "src="/resources/weekly_highlights/HighlightsList.txt" I can't figure out why this error is occurring. /resources/ is a virtual directory pointing to another server if that matters.
  3. I can't get file command like file($fileName) and file_exists($fileName) to work with a file stored on another server and accessible through a virtual folder. ie. /resources/ is a virtual folder pointing to a location on a remote server that is accessible via network file_exists("/resources/tmp/test.txt") doesn't work if the file is there. src = "/resources/tmp/test.txt" however does work oddly enough. Any ideas or suggestions?
  4. Converting PHP code into object-oriented paradigm. If you had to convert a regular php application of about 30 php files from non-object oriented to object oriented code, how long do you think it would take? How difficult do you think it is?
  5. I need the code in the following php file to run: ========'recentCampSettingsExcel.php'================== <?php include 'includes/php_includes.php'; session_start(); $_SESSION['firstTime'] = 'GIRL'; session_write_close(); //window.close(); ?> ================================================= I'm currently executing this file with the following line of code: <a href="javascript:void(0)" onclick=openPopup('recentCampSettingsExcel.php', 'recentCampSettingsExcel', 600, 500)"><b>(Export to Excel)</b></a> I don't want to open it up using a popup though. Is there some other function I can use that just executes whatever code is in the file without opening up anything?
  6. You mean like open up another popup that just sets the session variable and than closes itself?
  7. I see. Any ideas on how I can make this work? I need to set the variable whenever the link is clicked.
  8. The onclick action event handler is javascript
  9. It worked. Thanks guys. <a href="javascript:void(0)" onclick="<?php session_start();$_SESSION['firstTime'] = 'T';session_write_close();?>openPopup('recentCampSettingsExcel.php', 'recentCampSettingsExcel', 600, 500)"><b>(Export to Excel)</b></a>
  10. Well, that's the problem. I would have to reset it on the close event or the open event of the popup. I'm finding doing it on the close event is difficult, so I'm going to try to embed it into the line that opens the popup: <a href="javascript:void(0)" onclick="openPopup('recentCampSettingsExcel.php', 'recentCampSettingsExcel', 600, 500)">(Export to Excel)[/url] Any suggestions would be appreciated.
  11. I have a page that has a link that produces a popup when clicked <a href="javascript:void(0)" onclick="openPopup('recentCampSettingsExcel.php', 'recentCampSettingsExcel', 600, 500)"><b>(Export to Excel)</b></a> It calls the following php page which has rows of checkboxes that are linked to particular values in a database =================================================================== <?php include 'includes/php_includes.php'; include 'includes/header_simple.php'; function createMetricsListHTML($metricsArray, $curMetricsSelected, $curSelectAllFlags) { $groupNames = array( 1=> "General", 2 => "Buyer", 3 => "Seller", 4 => "Default"); $htmlOut = " <tr> <td class=\"tdcellgry\" valign=\"top\" align=\"right\"><b>Metrics:</b></td>"; foreach($metricsArray as $grouping => $metricsList) { $htmlOut.=" <td class=\"tdcellwhi\" valign=\"top\"> <table cellpadding=\"-1\" cellspacing=\"-1\" bgcolor=\"#FFFFFF\" width=\"100%\"> <tr><td class=\"tdcellgry\" align=\"center\"><i><b>$groupNames[$grouping]</b></i></td></tr>"; if(is_array($metricsList)) { foreach($metricsList as $oneMetric) { $htmlOut.=" <tr><td><input type=\"checkbox\" name=\"metrics[]\" value=\"$oneMetric[m_id]\""; if(in_array($oneMetric["m_id"], $curMetricsSelected)) { $htmlOut.=" checked"; } $htmlOut.="> $oneMetric[m_dispname]</td></tr>"; } } $htmlOut.=" </table> </td>"; } $htmlOut.=" <tr><td></td>"; foreach($groupNames as $key => $metricType) { $htmlOut.= "<td><input type=\"checkbox\" name=\"checkAll${metricType}\" value=\"true\" onclick=\"submit();\""; if($curSelectAllFlags[$key] == TRUE) { $htmlOut.= "checked > All $metricType</td>"; } else { $htmlOut.= " > All $metricType</td>"; } } $htmlOut .= "</tr>"; return $htmlOut; } $dashVars = DashboardDB::getDashboardSession(); $curChannel = $dashVars['recent_camps_channel']; $curTimeSpan = $dashVars['recent_camps_timespan']; $curLiveFlag = $dashVars['recent_camps_liveflag']; $curSelectAllFlags = $dashVars['select_all_flags']; $curMetrics = $dashVars['recent_default_camps_metrics'][$dashVars['metricType']]; $metricsArray = DashboardDB::getAvailableDisplayMetrics($curChannel); //$_REQUEST["checkAllDefault"] = true; $groupNames = array( 1=> "General", 2 => "Buyer", 3 => "Seller", 4 => "Default"); foreach($groupNames as $key => $metricType) { if($curSelectAllFlags[$key] != $_REQUEST["checkAll${metricType}"]) { //If boolean values don't match $curSelectAllFlags[$key] = !$curSelectAllFlags[$key]; //Switch boolean value //Process rows for metricType by new boolean value (all/none) $curChannelMetricsArray = $curMetrics[$curChannel]; if($curSelectAllFlags[$key] == true) { //All boxes set to checked foreach($metricsArray[$key] as $oneMetric) { if(!in_array($oneMetric['m_id'], $curChannelMetricsArray)) { // echo "WHAT THE ".$oneMetric['m_id']."BUCK"; $curChannelMetricsArray[] = $oneMetric['m_id']; } } } else { //All boxes set to unchecked foreach($metricsArray[$key] as $oneMetric) { if(in_array($oneMetric['m_id'], $curChannelMetricsArray)) { $removeKey = array_search($oneMetric['m_id'], $curChannelMetricsArray); // echo "WHAT THE ".$removeKey."BUCK"; unset($curChannelMetricsArray[$removeKey]); } } } sort($curChannelMetricsArray); $curMetrics[$curChannel] = $curChannelMetricsArray; $dashVars['select_all_flags'] = $curSelectAllFlags; $dashVars['recent_default_camps_metrics'][$dashVars['metricType']] = $curMetrics; } } if(isset($_REQUEST['exportSubmit'])) { $metrics = $_REQUEST['metrics']; $metricsLists = $dashVars['recent_export_camps_metrics']; //echo $dashVars['metricType']; $metricsLists[$dashVars['metricType']][$curChannel] = $metrics; //Saves data so DashboardDB can grab this data internally $dashVars['recent_export_camps_metrics'] = $metricsLists; $dashVars['channel']=$curChannel; DashboardDB::saveDashboardSession($dashVars); header('location:campExport.php'); } $metricsListHTML = createMetricsListHTML($metricsArray, $curMetrics[$curChannel], $curSelectAllFlags); DashboardDB::saveDashboardSession($dashVars); ?> <form name="recentCampSettings" action="#" method="post"> <input type="hidden" name="channel" value="<?php echo $curChannel?>"> <body "javascript:void(0)" onSubmit=<?php $dashVars['submit'] = 'T'; DashboardDB::saveDashboardSession($dashVars)?>> <table cellpadding="1" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td class="tblhdrpri" colspan=5><b>Select Fields to Export</b></td> </tr> <!--<tr> <td class="tdcellgry" align="right"><b>Include Live:</b></td><td class="tdcellwhi" colspan=4><input type="checkbox" name="livecheck" <?php if($curLiveFlag) {echo "checked";}?>></td> </tr>--> <?php echo $metricsListHTML?> <tr cellpadding="1" cellspacing="1"> <td class="tdcellwhi" align="center" colspan=5><input type="submit" name="exportSubmit" value="Export Submit"></td> </tr> </table> </body> </form> <?php include 'includes/footer_simple.php'; ?> ========================================= There are checkboxes at the bottom row that select all the values for the column that they belong to. I want one of the check all in column checkboxes to start out checked when the popup is opened though. For this to work, the popup needs to know the first time it was opened. Someone previously suggested using a session variable. This is great, except that I have to unset it when the popup is closed, and I can't do that without breaking the checkbox feature. I can do it using an onunload event handler, but the submit() function in the $htmlOut.= "<td><input type=\"checkbox\" name=\"checkAll${metricType}\" value=\"true\" onclick=\"submit();\""; line also triggers it every time the user clicks on a select all in column checkbox.
  12. The problem I have with the session is getting rid of the variable. I'd have to know the first time the popup window was opened, and I'm finding that to be a lot more difficult than it seems.
  13. How do send a post variable to the next form? I don't want to do it through a checkbox, sessions, cookies, or any kind of user input field. I just want something like $_POST['thisvar'] = 'VarOne'; to send a post variable to the new form when it is submitted.
  14. How would I do that? Is there some kind of opener.close() javascript function I can use? I would prefer to use one that doesn't use an echo statement.
  15. I have an additional problem now. I need the session variable to be cleared when the popup window that created it closes. I can't use the javascript onunload even handler though because some of my checkboxes in the popup use the submit() function, and I can't have the session variable clearing every time someone clicks on a checkbox. I only want to clear it once the actual popup is closed. Here is the relevant code: ===================================== <form name="recentCampSettings" action="#" method="post"> <input type="hidden" name="channel" value="<?php echo $curChannel?>"> <body "javascript:void(0)" onUnload=<?php $dashVars['submit'] = 'T'; DashboardDB::saveDashboardSession($dashVars)?>> <table cellpadding="1" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td class="tblhdrpri" colspan=5>Select Fields to Export</td> </tr> <!--<tr> <td class="tdcellgry" align="right"><b>Include Live:</b></td><td class="tdcellwhi" colspan=4><input type="checkbox" name="livecheck" <?php if($curLiveFlag) {echo "checked";}?>></td> </tr>--> <?php echo $metricsListHTML?> <tr cellpadding="1" cellspacing="1"> <td class="tdcellwhi" align="center" colspan=5><input type="submit" name="exportSubmit" value="Export Submit"></td> </tr> </table> </body> </form> ======================== Here is the code for the checkbox that submits the form and also triggers the onUnload event handler against my wishes $htmlOut.= "<td><input type=\"checkbox\" name=\"checkAll${metricType}\" value=\"true\" onclick=\"submit();\""; Any help would be appreciated
  16. It's a popup window that's opened using javascript, but it's contents are primarily php. Here's the line that calls it. <a href="javascript:void(0)" onclick="openPopup('recentCampSettingsExcel.php', 'recentCampSettingsExcel', 600, 500)"><b>(Export to Excel)</b></a> My problem remains unchanged. I need the popup window to simultaneously redirect to another php page, and also close itself.
  17. I have a popup window full of php, and in it is this piece of code which executes when the window closes.. <body "javascript:void(0)" onUnload=<?php $dashVars['firstTime'] = 'T'; DashboardDB::saveDashboardSession($dashVars)?>> It works fine except I also have another line of code in the php that submits the form to itself $htmlOut.= "<td><input type=\"checkbox\" name=\"checkAll${metricType}\" value=\"true\" onclick=\"submit();\""; And whenever this line of code executes, refreshing the popup window, the onUnload event will trigger. I need an event trigger for when the popup wnidow really closes and not just when it's being refreshed. Please help.
  18. I have a php popup window that I want to do 2 things. I want it to call the php script campExport.php and also close itself at the same time. Can anyone help me? =============== echo "<SCRIPT LANGUAGE=\"JavaScript\"> window.close();</script>"; header('location:campExport.php');
  19. I'm confused about where I should reset the counter to 0. Can I embed that into the call to the php page? <a href="javascript:void(0)" onclick="openPopup('recentCampSettingsExcel.php', 'recentCampSettingsExcel', 600, 500)"><b>(Export to Excel)</b></a> Is there a way for me to stick a $_SESSION['counter']=0 within that line of code? I can't set the session variable to 0 within the 'recentCampSettingsExcel.php' page itself. Or it will get called every time. Otherwise I don't see a way to do it using session variables. I'm finding it faintly ridiculous that there isn't a simpler way to tell the first time a page is called. I think this would be an important piece of information that is used often.
  20. That doesn't work because sometimes the $_POST['checkboxname'] variable isn't set after the form is submitted. It's only set if the checkbox has been clicked on. Isn't there some way to tell the first time a form is opened by a user? I'd settle for an inelegant solution. Something like $count=0; <form is submitted> $count++; That doesn't work though because the $count=0 part get re-executed every time.
  21. I don't want to post the whole thing. It's just too big. My problem is that I need a variable to be defined the ONLY the first time a form is called. ie. $checkAllDefault=true; The form has a submit() function tied to a checkbox: <td><input type=\"checkbox\" name=\"checkAll${metricType}\" value=\"true\" onclick=\"submit();\ And when the user clicks on that checkbox and the form reloads, I need the variable $checkAllDefault=true; to not be defined, because it's tied to one of the other checkboxes and it won't do what I want it to if it's hardcoded. It seems like a simple problem, but I can't figure a way around it. I thought I could use a counter but those get reset every time the page is loaded too. How do I know the first time a page is called?
  22. I have a problem where I need a $_REQUEST variable to appear the first time I call a page, but need it to disappear for each successive "submit()" of that page. The line that calls the page is: <a href="javascript:void(0)" onclick="openPopup('recentCampSettingsExcel.php?checkAllDefault=true', 'recentCampSettingsExcel', 600, 500)"><b>(Export to Excel)</b></a> I need that $_REQUEST variable to be defined when the php page is first show. But the page has a submit() feature. And each time that submit feature is pressed I need the original $_REQUEST to disappear. But I can't get it to go away, like it's hardcoded to the php form. I've tried unset() and reassigning it. It just resets to its original value each time. I've thought of maybe assigning it in the called page, but I can't figure out a way to get it to be defined only the first time it's called there either. I would appreciate any help.
  23. Why doesn't the following line workin in php? echo "$_REQUEST[/'checkAllDefault/']"; I get the error message: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in
  24. That's the problem. Functions like windows.close() don't work after you specify the header information for the Excel Export in php. ie. ============================== header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=\"$fileName\""); ... echo "\tfield1\tfield2"; ... echo "<SCRIPT LANGUAGE=\"JavaScript\"> window.close();</script>"; ================================= The javascript will get written into the Excel file. Is there some way I can stop the writing to Excel, so I can get the javascript to execute.
×
×
  • 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.