Jump to content

southofsomewhere

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

southofsomewhere's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Alright.. done to the point of.. I need to be able to sort by a given member (which should be fairly easy, but as stated before I can't find where cmp_obj's param's are being passed.) <?php // get all of the group objects associated with this orgID for($z = 0; $z < count($orgArr); $z++) { // if the current objects orgID is equal to the orgID we're wanting to sort if($orgArr[$z]->orgID == $orgID) { // put the object in the new array $curOrgArr[$z] = $orgArr[$z]; } } usort($curOrgArr, array("OrganizationViewManager", "cmp_obj")); ?> is what I have for the initializing array/sorting.. and then the cmp_obj function, pulled from php.net.. <?php static function cmp_obj($a, $b) { $al = strtolower($a->numStudents); $bl = strtolower($b->numStudents); if ($al == $bl) { return 0; } return ($al > $bl) ? +1 : -1; } ?> last issue: I need to be able to change $a->numStudents and $b->numStudents.. and the way I could think of doing it is adding an extra param.. but as you see (or at least I dont), I don't see where one could do this. Thanks.
  2. Did some looking into usort (actually had the php.net page open while reading your response), and I'm not sure if it works yet as I'm trying to figure out what the first value in the array function actually is (constructor.. class name.. object name..), and I don't quite get how its comparing since cmp_obj is never really called with two values to compare to. .. but I'm probably missing something. Edit: <?php // get all of the group objects associated with this orgID for($z = 0; $z < count($orgArr[$z])) { if($orgArr[$z]->orgID == $orgID) { $curOrgArr[$z] = $orgArr[$z]; } } I set it up so I don't even have to sort a portion of the array, but an entire array. So all thats left is sorting via a class member.
  3. Alright, I essentially have an array of objects, and I'm trying to figure out how it would be possible to sort the array (or even a portion of the array) by an instance variable in the object.. in the array. e.g. arr[0] => myObject->schoolID = 1337; arr[0] => myObject->age = 5; arr[0] => myObject->name = "mary"; arr[1] => myObject->schoolID = 1337; arr[1] => myObject->age = 2; arr[1] => myObject->name = "joe"; arr[2] => myObject->schoolID = 42; arr[2] => myObject->age = 2; arr[2] => myObject->name = "sue"; so in the above example, how could I go by taking all of the people with schoolID 1337, and sort them by age. Thanks
  4. Solution: I had to tack on text to the variable in the Session initialization for it to work.. do you HAVE to have text in the session index for some reason? E.g. $_SESSION[$orgID] = "name"; // this wont work $_SESSION['id_'.$orgID] = "name"; // this works.
  5. Made a quick file to essentially do.. what I'm doing in a nutshell and yielding the same results. <?php session_start(); if(isset($_GET["create"])) { $sortContents = explode(".", $_GET["create"]); $orgID = $sortContents[0]; $sortBy = $sortContents[1]; $_SESSION[$orgID] = $sortBy; } echo "created sessions: <br />"; print_r($_SESSION); ?> tested via: filename.php?create=a_number.a_word
  6. I have a file that keeps track of ID's and how you want that ID group sorted. Essentially, I have a $_GET variable that contains a value such as: 1000.name I then take this value and explode it, to create $orgID and $sortBy. I then create a session like so: $_SESSION[$orgID] = $sortBy; It appears as if only the most recent session that was set is being displayed, as doing a dump only shows the last one set. Below is a brief overview of what I've got going. session_start(); if(isset($_GET["setorder"])) { $sortContents = explode(".", $_GET["setorder"]); $orgID = $sortContents[0]; $sortBy = $sortContents[1]; $_SESSION[$orgID] = $sortBy; } echo $_SESSION[1000]; echo $_SESSION[1001]; Assuming we go to the page with 1000.name first, and then 1001.title second.. first glance will show "name", which is correct. going to the page a second time will only show "title", ignoring the 1000. Suggestions?
  7. Long story short.. I'm trying to devise a way to be able to collapse/expand multiple tables, and be able to sort them when they're expanded. Each table is a different row of a MySQL query, where the first table that will always be displayed no matter what displays information about the organization.. and the second query deals with looping through that organizations records and displaying the members associated with it. These tables are in nested for-loops.. where the first for prints off information about the organization (which will always be shown), and the 2nd displays the actual members of the organization (this is the part I wish to collapse/expand and sort via name, admin, students). Main issue I'm having is to how to go about managing all of the possibilities.. you could have multiple organizations expanded and sorted all in different ways, and trying to use a $_GET in some way shape or form would probably produce a very complex and long string in the end. I've been looking into some JavaScript possibilities, but that route could get tricky as well linking 3 lists to each other and importing an sql query into them.. but its food for thought. If any further explanation is required feel free to inquire. Thanks
  8. You're.. seriously not even trying at this point. You're calling the row assoc on $result when the variable is $results
  9. What I'm trying to say is.. for the.. 3rd time.. is that the email address is never set, initialized, declared, given a value .. so when you call mail().. the email is being sent.. to.. no one.
  10. .. are you reading the responses .. ? $email isn't being initialized anywhere that I can see..
  11. I'm not quite sure I understand the reasoning for this query: // Set up the query. $query = "UPDATE users SET active=NULL WHERE user_id=$id"; If this is just a default.. then you can set the default value in the MySQL table (it appears to be a default setting you want anyway, don't know why you'd set it to NULL on the fly for any other reason) .. anyway .. It doesn't appear you're actually initializing $email to ever be anything, thus when you call mail(), it's not being sent to anywhere but a blank variable.
  12. echo "<td><a href=somesite.com><img src=upload/".$row['name']."></a></td>"; Just need to put the ahref tag around your image.
  13. I would highly suggest having a "monthid" to organize your months via a numerical value (e.g. Jan=1, Feb=2, etc) echo "<select name=months>"; $db->query('SELECT Month FROM table_name ORDER BY monthid ASC'); foreach($db->rows as $month) { echo "<option value = " . $month.monthid . ">" . $month.Month . "</option>"; } echo "</select>"; Where $db->rows is your mysql result of all of the month names in the table $month = the variable assigned to each row, and the period after it gets that column. You'll need to replace table_name with the name of the table these months are in You'll want to ORDER BY ASC so that the month's are ordered from 1 to 12, and that way you'll get them in order. $month.monthid returns the monthid of the current month it's looping through (so 1 for january).. and this'll be your VALUE. Then $month.Month returns the actual month name, which will be visible to the user. (assuming you named that column Month) If you're not using an ADO.. echo "<select name=months>"; $sql = mysql_query("SELECT Month FROM table_name ORDER BY monthid ASC"); while($row = mysql_fetch_array($sql)) { echo "<option value = " . $row['monthid'] . ">" . $row['Month'] . "</option>"; } echo "</select>"; .. may be an easier way to look at things.
  14. #1 I don't see you initializing $email anywhere in your source. #2 (the array issue): Your using the same id for your label, as you are for your textbox. Change the label to lblName or something other than what your textbox is named. <label for="lname">Last name</label> </td> <td> <input type="text" name="lname" id="lname" size="20" />
×
×
  • 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.