Jump to content

Jim from Oakland

Members
  • Posts

    41
  • Joined

  • Last visited

Everything posted by Jim from Oakland

  1. Phreax User responses to individual forms are stored in arrays as shown below.  I will gather all such results into one large results array with the same structure/keys.  I'd sure appreciate your assistance with a way to sort the results array by each of the three second dimension keys, as described below.  Responses from one form: aItemsArray[1]['Category']=1; aItemsArray[1]['Subject']="Car Color"; aItemsArray[1]['Response']="Blue"; aItemsArray[2]['Category']=1; aItemsArray[2]['Subject']="Car Size"; aItemsArray[2]['Response']="Small"; aItemsArray[3]['Category']=2; aItemsArray[3]['Subject']="House Color"; aItemsArray[3]['Response']="Orange"; aItemsArray[4]['Category']=2; aItemsArray[4]['Subject']="House Size"; aItemsArray[4]['Response']="Medium"; For the results array: The order (of the first dimension numeric "index" keys) of the results array reflects a) items being grouped (sorted) by category, b) within each category items are sorted by Subject and c) within each subject items are sorted by Response.
  2. In the array (shown below) I need to change the 'name' of one of the (first level) keys. In the example, I'd like to change the key 'Boat' to 'Ship' without changing the order of the array entries. ['Car']['ID']='445'; ['Car']['Color']='blue'; ['Car']['Note']='needs work'; ['Boat']['ID']='491'; ['Boat']['Color']='green'; ['Boat']['Note']='for sale'; ['Plane']['ID']='420'; ['Plane']['Color']='azure'; ['Plane']['Note']='ready'; Thanks a billion!
  3. I have a php app that generates a form that "imports" a lot of js scripts, conditionally, depending on needs.  I use the file_get_contents function to load content of the js files into a php var which is then appended to the html content.  Make sure that any necessary <script> tags are in the "js" files.  Works great! Jim
  4. I hope to avoid the need for a file to "populate" the help window. I really want to open a new window (for help) and put the help content/message into the window when a user clicks a link or if necessary a button. If I have to use a simple js function in <head> that is fine, buttons are ok too. pseudo(lameo)code <head> <script language="javascript"> function hlpWin($pContent='') {   var $Name = 'Help';   var hlpWin = window.open('',$Name,height=200,width=200);   hlpWin.write($pContent); } </script> </head> <a onClick=hlpWin("<b>Help</b> for item 1 is on the way...")>Help 1</a>
  5. Array named $accountData is structured as shown below. How do I loop all entries in the first dimension (there are 3 in the example) to access a specific 2nd dimension key within each (such as the Value key in the example)? I assume I need some form of foreach but I can't figure it out. [UserID][Label]="User Identifier" [UserID][Value]="Q2ED" [UserID][Help]="This is yourprimary ID #" [UserID][Note]="First entered March 2003" [UserType][Label]="User Type" [UserType][Value]="Gold" [UserType][Help]="This refers to your account category" [UserType][Note]="Upgrade is pending." [UserName][Label]="User Name" [UserName][Value]="Bill Derr" [UserName][Help]="We must have your name." [UserName][Note]=""
  6. Javascripters I'm not familiar enough with javascript to hack even this most basic need: I've got a php app and I hope to add help that is shown in a separate window when user clicks on a link (or button, if that helps).  But, I want to send a string to the window as content, instead of specifiying a file (which I know how to do). Thanks a lot.
  7. Thanks again I appreciate your assistance, a lot. Unfortunately it is still not working; the array is reordered but not sorted. I note that the static keyword fails on my system; I'm using 4.3. I modified code just a bit to match my class's names. <? class TableData { var $dataTableArray; var $sortKey; function TableData($data) {     $this->dataTableArray = $data; } function data_array_sort($key) {   $this->sortKey = $key;   usort($this->dataTableArray, "TableData::mySort");   return $this->dataTableArray; } function mySort($a, $b) {   return strcmp($a[$this->sortKey], $b[$this->sortKey]); } }//end class $dataArray[1]['UserID'] = 'dr45'; $dataArray[1]['FName'] = 'Joe'; $dataArray[1]['LName'] = 'Smith'; $dataArray[2]['UserID'] = 'qz50'; $dataArray[2]['FName'] = 'Huan'; $dataArray[2]['LName'] = 'Lee'; $dataArray[3]['UserID'] = 'aw13'; $dataArray[3]['FName'] = 'Zoey'; $dataArray[3]['LName'] = 'Zeus'; $dataArray[4]['UserID'] = 'mm61'; $dataArray[4]['FName'] = 'Have'; $dataArray[4]['LName'] = 'Hope'; $obj = new TableData($dataArray); $sortedData = $obj->data_array_sort('LName'); echo '<pre>', print_r($sortedData, true), '</pre>'; ?>
  8. Barand OK. In the spirit of being brief I left out the fact that the array is a class property and that the sorting logic is for a method inthe same class. So, how do I tell usort about the function if "mySort" is a method in the same class as the array?  And, presumably the global scoping will work "within" the class? class arrayManager { //loaded by caller var $dataArray; // data_array_sort method function data_array_sort() {   return usort($this->dataArray, 'mySort'); } function mySort($a, $b) {   global $gSortKey;   strcmp($a[$gSortKey], $b[$gSortKey]); } }//end class
  9. Barand That is great!  Thanks very much. If you are inclined to share a bit more of your knowledge... Can you give just a bit of explanation about what your approach does? Also I generalized it so it will work with any key. function sort_by_key ($key, $a, $b) {     return strcmp($a[$key], $b[$key]); } $dataArray[1]['UserID'] = 'dr45'; $dataArray[1]['FName'] = 'Joe'; $dataArray[1]['LName'] = 'Smith'; $dataArray[2]['UserID'] = 'qz50'; $dataArray[2]['FName'] = 'Huan'; $dataArray[2]['LName'] = 'Lee'; $dataArray[3]['UserID'] = 'mm61'; $dataArray[3]['FName'] = 'Have'; $dataArray[3]['LName'] = 'Hope'; $key = 'LName'; usort ($dataArray, sort_by_key($key));
  10. Phreax: I need to sort the array based on the second dimension key named LName Array is configured like this: $dataArray[1]['UserID'] = 'dr45'; $dataArray[1]['FName'] = 'Joe'; $dataArray[1]['LName'] = 'Smith'; $dataArray[2]['UserID'] = 'qz50'; $dataArray[2]['FName'] = 'Huan'; $dataArray[2]['LName'] = 'Lee'; Thanks so much!
  11. thanks ray I gave too little background: I use 4.31 and Apache on my Windows XP system. And I found that the php copy file system function works fine. [!--quoteo(post=360450:date=Apr 1 2006, 02:23 AM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ Apr 1 2006, 02:23 AM) [snapback]360450[/snapback][/div][div class=\'quotemain\'][!--quotec--] You won't be able to do it unless you make your computer into a web server, with php installed on it, or install an ftp server on your box. You cannot make your web server go out and "push" files to another computer unless you have ftp. You could do this all thru command line though and then put it into a scheduled task. It is pretty easy to do. Let me know if you want to do it and I will give you some code. Ray [/quote]
  12. Phreax On my Windows XP PC my php script iterates through monthly zip files on a public website so it can "copy" them to the directory on my PC containing the script. Here is one of the files. [a href=\"http://mis.nyiso.com/public/csv/damlbmp/20050301damlbmp_zone_csv.zip\" target=\"_blank\"]http://mis.nyiso.com/public/csv/damlbmp/20...mp_zone_csv.zip[/a] How do I tell php to put a copy of that file on my PC in the script's directory? Thanks much! Jim
  13. no i just did that to verify that my code was actually affecting settings. I turned \"ALL\" on then checked the status then I turned everything off and checked again. It changed so I know code is working. In the actual script I set it to ALL. For the record my php.ini settings are error_reporting = E_ALL display_errors = On display_startup_errors = On log_errors = On log_errors_max_len = 1024 ignore_repeated_errors = Off track_errors = Off I must be missing something basic? Is there something in Apache I should look at? Thanks sooo much.
  14. Team AphpACHE On Windows XP Home (development only) I have been trying to get php (Apache?) to show error messages in my browser. I changed the php.ini (shown below). I issue commands in code (shown below) to tell php to show errors, yet when an error occurs the screen goes blank. Might I need Apache settings, do I need some sort of \"template\" (html?) document? Jim -------- *** CODE *** I use to verify that settings change, they do. error_reporting(E_ALL); Echo \'<br>error_reporting = ALL: \' . error_reporting(); error_reporting(0); Echo \'<br>error_reporting = NONE: \' . error_reporting(); Here are *** php ini *** settings. display_errors = On display_startup_errors = On log_errors = On log_errors_max_len = 1024 ignore_repeated_errors = Off track_errors = Off Not set (php initial settings/default) ;docref_root = /phpmanual/ ;docref_ext = .html ;error_prepend_string = \"<font color=ff0000>\" ;error_append_string = \"</font>\" ;error_log = filename ;error_log = syslog
  15. effigy Thanks. As the military folks say, \"I\'m looking through a staw\" when dealing with servers and the greater php environment -- but I am enjoying programming! Question: when I first started hacking (on ISP\'s severs) html form \"variables\" seemed to show up in the \"called\" script \"automatically.\" That is, if I have a hidden control named Test and in Screen1.php then in the script posted to (e.g. screen2.php) I could immediately refer to the variable named $Test without the intermediate step of accesing $_POST[\'Test\'] A barely related question: When testing on ISP server (apparently Netscape web server) I got error messages. They were not very helpful but at lest they reported the offending line. Can I do that with Apache? Thanks a billion! Jim
  16. Effigy I am doing nothing exotic, just basic html form In fact, though I am doing pretty well with php itself, topics that are more system and server oriented are totally unfamiliar to me. I doubt it will help much but here is an excerpt of my code. It all works fine on my ISP\'s server. But he does not want me to use his sever for development so I need to work on my own machine. Apache and php seem to be running fine, I just need to set some stuff in Apache I\'m sure. Thanks so much for the help. <?php // the name of the file to post to is in the variable $postToFileName Echo\'<form name=\"mail\" method=\"post\" action=\"\' . $postToFileName .\'\">\'; ?> Snip <?php Echo(\'<Input type=\"hidden\" name=\"\' . \'Item\' . $ItemIndex . \'ID\' . \'\" value=\"\' . ${\'Item\' . $ItemIndex . \'ID\'} . \'\">\'); ?> Snip <input type=\"submit\" name=\"submit\" value=\" Check-in \">
  17. Team PHP I am hoping to do PHP development without having to become an Apache jocky (jock?). I just downloded and installed Apache and php. Html forms do not \"push\" values into the next script. I sure hope there is a \"just do this\" setting for the apache server... XP Home. What is the best source for BASICS about running Apache and PHP? Jim
×
×
  • 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.