Jump to content

rasherb

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rasherb's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I did this: works fine for me. Spits out "M" and the multi-modes if it is a multi-modal array. "M 4 5" or "M 5 3 1" case 'mode': $v = array_count_values($array); arsort($v); foreach($v as $key => $k){ if ($k == max($v)){ $modearray[]=$key; } } if (count($modearray)>1){ $total = "M"; $i = 0; while ($i < count($modearray)){ $total .= " $modearray[$i]"; $i++; } } else { $total = $modearray[0]; } break;
  2. Found this to calculate mode from an array: function mmmr($array, $output = 'mean'){ if(!is_array($array)){ return FALSE; }else{ switch($output){ case 'mode': $v = array_count_values($array); arsort($v); foreach($v as $k => $v){$total = $k; break;} } return $total; } } But some of the arrays are multi-modal: array(5,5,5,3,3,3,2,2,1) 5 and 3 are modes for this array. Can someone help me change the mmmr function above to return an average of modes if the array is multi-modal? Thanks!
  3. Hi! I have an array sort of like this example I found: $cds = array( 'Christina Aguilera'=>array( 'Impossible', 'Beautiful', 'Dirrty' ), 'Pink'=>array( 'Just like a pill', 'Family potrait', 'Missundaztood' ), 'Kelly Rowland'=>array( 'Stole', 'Obsession', 'Past 12' ) What I need to do is pull off all of the, for example, 'Pink' albums and make a single array from those values. This is my real array: $importarray[$i][$m] I need to make an array of all the sub-values ($m) at a certain value of $i. What can I do? Thanks!
  4. Only hang up is I need to name all of my divs individually and uniquely. Can anyone help me with a function where I can show/hide individual divs, but keep the same id on all divs? The thing looks like this for a javascript show/hide: <?php <head> <script language=javascript type='text/javascript'> function showhide(id){ if (document.getElementById){ obj = document.getElementById(id); if (obj.style.display == \"none\"){ obj.style.display = \"\"; } else { obj.style.display = \"none\"; } } } </script> </head> echo "<a href=\"#\" onclick=\"showhide('titlebox'); return(false);\"><img border=\"0\" src=\"open.gif\">"; echo "<div id=\"titlebox\" style=\"display: none;\">"; echo "<form name=\"form\" method=\"post\" action=\"submit.php?useridnum=$usernum\">"; echo "Title: <input type=\"text\" name=\"title\" size=\"70\"></textarea>"; echo "<a href=\"\"><img border=\"0\" src=\"openclose.gif\">[/url]"; echo "Category: <input type=\"text\" name=\"category\" size=\"70\"></textarea>"; echo "Stakeholders: <input type=\"text\" name=\"stake\" size=\"70\"></textarea>"; echo "Objective: <input type=\"text\" name=\"objective\" size=\"70\"></textarea>" echo "</div>"; echo "<a href=\"#\" onclick=\"showhide('subtitlebox'); return(false);\"><img border=\"0\" src=\"open.gif\">"; echo "<div id=\"subtitlebox\" style=\"display: none;\">"; echo "Title2: <input type=\"text\" name=\"title2\" size=\"70\"></textarea>"; echo "<a href=\"\"><img border=\"0\" src=\"openclose.gif\">[/url]"; echo "Category2: <input type=\"text\" name=\"category2\" size=\"70\"></textarea>"; echo "Stakeholders2: <input type=\"text\" name=\"stake2\" size=\"70\"></textarea>"; echo "Objective2: <input type=\"text\" name=\"objective2\" size=\"70\"></textarea>" echo "</div>"; echo "<div>"; echo "<input type=\"submit\" value=\"Submit\" />"; echo "</div>"; ?>
  5. Nevermind. Solved using the Internets!
  6. Can someone help me make parts of a page show/hide when the user clicks a button? I'm writing in PHP now, but I hear javascript will do this better, particularly because I am trying to show/hide parts of a form while retaining user input. Say this is my page: <?php echo "<div>"; echo "<form name=\"form\" method=\"post\" action=\"submit.php?useridnum=$usernum\">"; echo "Title: <input type=\"text\" name=\"title\" size=\"70\"></textarea>"; echo "<a href=\"\"><img border=\"0\" src=\"openclose.gif\"></a>"; echo "Category: <input type=\"text\" name=\"category\" size=\"70\"></textarea>"; echo "Stakeholders: <input type=\"text\" name=\"stake\" size=\"70\"></textarea>"; echo "Objective: <input type=\"text\" name=\"objective\" size=\"70\"></textarea>" echo "</div>"; echo "<div>"; echo "Title2: <input type=\"text\" name=\"title2\" size=\"70\"></textarea>"; echo "<a href=\"\"><img border=\"0\" src=\"openclose.gif\"></a>"; echo "Category2: <input type=\"text\" name=\"category2\" size=\"70\"></textarea>"; echo "Stakeholders2: <input type=\"text\" name=\"stake2\" size=\"70\"></textarea>"; echo "Objective2: <input type=\"text\" name=\"objective2\" size=\"70\"></textarea>" echo "</div>"; echo "<div>"; echo "<input type=\"submit\" value=\"Submit\" />"; echo "</div>"; ?> I want to hide/show using javascript enabled buttons (onclick?) instead of the links. Never programmed javascript before. Can anyone help?
  7. Well, time to learn some javascript... Thanks all!
  8. The form has sections (it's huge) I use links and if(isset){} to expand and contract the sections so they are not all on the page at once, confusing the heck out of users.
  9. Thanks, So if I use a link to refresh the page... <?php echo "<form name=\"form\" method=\"post\" action=\"submit.php?useridnum=$usernum\">"; echo "Title: <input type=\"text\" name=\"title\" size=\"70\"></textarea>"; echo "<a href=\""; echo $_SESSION['PHP_SELF']; echo "?show=1\"><img border=\"0\" src=\"close.gif\"></a>"; ?> Where would the java go?
  10. I really want reload a page I have with a huge form on it without losing any information users have typed into the form. Can php access form data before the form is submitted like javascript (document.form.name.value)? Any other ideas for keeping form data on refresh without submitting the form? Any help would be much appreciated!
  11. I've got WAMP5 installed. I'm re-running the scripts now. May be fine after all... Thanks!
  12. <?php echo "<html>test</html>"; ?> This prints out in the browser as test"; ?> I just want: test ???
×
×
  • 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.