Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. echo mysql_result(mysql_query('SELECT field_name FROM table_name WHERE condition ORDER BY field_name DESC LIMIT 0, 1'),0,0)+1;
  2. no try <?php $_REQUEST['phone'] = '123-456p'; if (eregi('[a-z]+', $_REQUEST['phone'])) echo 'some leters'; else echo 'no leters'; ?>
  3. try ... //$ageTime = mktime(0, 0, 0, ($Month), ($Day), ($Year)); // Get the person's birthday timestamp $ageYears = date('Y') - $Year; $ageYears -= (date('m') * 100 + date('d')) < ($Month * 100 + $Day) ? 1 : 0; //$t = time(); // Store current time for consistency //$age = ($ageTime < 0) ? ( $t + ($ageTime * -1) ) : $t - $ageTime; //$year = 60 * 60 * 24 * 365; echo $ageYears; ...
  4. change line if ($rows['name'] != $lastgroup) { to if ($rows['group_id'] != $lastgroup) { and $lastgroup = $rows['name']; to $lastgroup = $rows['group_id'];
  5. <?php $info = 'recon Mission Report Under the cover of night, your 208,000 Covert Ops sneak into the realm of Jungleman . Your Covert Ops move stealthily through the lands of Jungleman undetected. They are able to gather many documents recording the status of weapons, army size and preparedness, and fortifications. Unfortunately, in order to avoid detection, they are not able to provide complete information. Your Chief of Intelligence provides you with the information gathered: Army Size: Unit Type Attackers Defenders Untrained Mercenaries 0 18 0 Soldier 0 0 158550 NID Agent 200 19 66897 Military Stats Strike Action: 24,548,048 Defensive Action 0 Covert Action: 22 AntiCovert Action 22 Covert Skill: 21 Covert Operatives: 0 Anti-Covert Skill: 0 Anti-Covert Operatives: 0 Attack Turns: 3999 Unit Production: 7244'; $find = array( ' ', ','); $replace = array(' ', ''); $info = str_replace($find, $replace, $info); preg_match_all('/.+ [0-9]+/', $info, $a); foreach ($a[0] as $k => $v) { preg_match_all('/([^0-9]+) ([0-9 ]+)/', $v, $b); $c[$b[1][0]] = explode(' ',$b[2][0]); } //print_r($c); //$fild_for_sum = array('bot', 'Units', 'Human Form Units','Covert Operatives:','Anti-Covert Operatives:'); $fild_for_sum = array('Mercenaries', 'Soldier', 'NID Agent','Covert Operatives:','Anti-Covert Operatives:'); $u = array(''); foreach ($fild_for_sum as $k) $u = array_merge($u, $c[$k]); for ($i = 1; $i < 12; $i++) { $n = 'unit'.$i; $$n = $u[$i]; } $AT = $c['Attack Turns:'][0]; $unitp = $c['Unit Production:'][0]; echo " unit1 = $unit1, unit2 = $unit2, unit3 = $unit3, unit4 = $unit4, unit5 = $unit5, unit6 = $unit6, unit7 = $unit7, unit8 = $unit8, unit9 = $unit9, unit10 = $unit10, unit11 = $unit11, AT = $AT, unitp = $unitp"; ?>
  6. try <?php function ArrayLocate($srch,$haystack) { $out = array(); foreach ($srch as $k => $v) { foreach ($haystack as $key => $h) { if ($h[$k] == $v) $out[] = $key; } } return $out; } $haystack = array( array('id' => 1, 'name' => 'fernando', 'age' => 20), array('id' => 2, 'name' => 'jean', 'age' => 18), array('id' => 3, 'name' => 'paul', 'age' => 23), array('id' => 4, 'name' => 'bob', 'age' => 20), array('id' => 5, 'name' => 'richard', 'age' => 28), ); $z = ArrayLocate(array('age' => 20),$haystack); print_r($z); ?>
  7. try <?php function csvToArray($csvFile, $linelen) { if (($contents = $csvFile) === false) { return false; } $fi_co = 0; $result = array(); $tarray = array(); while ($contents){ $word = ""; $delim = (++$fi_co % $linelen) ? ',' : "\n"; $pos = -1; do { if(($pos = strpos($contents, $delim, ++$pos)) === false) $pos = strlen($contents); $word = substr($contents, 0, $pos); $x = substr_count($word, '"') % 2; $pos; } while ($x) ; if (($fi_co % $linelen) == 1) $tarray = array($word); else $tarray[] = $word; if ($fi_co % $linelen == 0) $result[] = $tarray; $contents = substr($contents, $pos+1); } if ($fi_co % $linelen != 0) $result[] = $tarray; return $result; } // parse CSV file with line breaks and quotes $a = 'Column 1,Column 2,Column 3,Column 4 Data 1,Data 2,Data 3,"This is a text field into which has been entered lots of data, including line breaks: like this. Also, there are quotes like this: "This is a quote, quote, quote." Notice how the quotation mark proceeded a line break? This is the end of column 4." Data 6,Data 7,"Data "sasa" 8","Data Data Data"'; $m = csvToArray($a,4); print_r($m); ?>
  8. change method="$_POST" to method="POST" variable $_POST is empty and the form use deaful method
  9. i try with your string and output look X-Powered-By: PHP/4.4.4 Content-type: text/html 119 - -<br /> 128 - 2<br /> 129 - 3<br /> 130 - -<br /> 132 - -<br /> 141 - -<br /> 152 - -<br /> 153 - -<br /> 154 - -<br /> 155 - -<br /> 186 - -<br /> 195 - -<br /> 198 - -<br /> 223 - -<br /> 226 - 2<br /> 119 - -<br /> 128 - -<br /> 129 - -<br /> 130 - -<br /> 132 - -<br /> 141 - -<br /> 152 if you want just output this, string is OK if you want some calculation with data array is better
  10. $pageprev = $page--; must be $pageprev = $page-1; and $pagenext = $page++; must be $pagenext = $page+1; BTW can somebody correct this tutorial
  11. try <?php $string = '&=119=-&=128=2&=129=3&=130=-&=132=-&=141=-&=152=-&=153=-&=154=-&=155=-&=186=-&=195=-&=198=-&=223=-&=226=2&=119=-&=128=-&=129=-&=130=-&=132=-&=141=-&=152'; echo $string = str_replace('=', ' - ', str_replace('&=', "<br />\n", trim($string, '&='))); ?>
  12. try <?php $info = 'bot 0 0 0 Units 0 0 7227 Human Form Units 100000 930000 1478941 Covert Operatives: 1050000 Anti-Covert Operatives: 0 Attack Turns: 633 Unit Production: 4544 '; $find = array( ' ', ','); $replace = array(' ', ''); $info = str_replace($find, $replace, $info); preg_match_all('/.+ [0-9]+/', $info, $a); foreach ($a[0] as $k => $v) { preg_match_all('/([^0-9]+) ([0-9 ]+)/', $v, $b); $c[$b[1][0]] = explode(' ',$b[2][0]); } //print_r($c); $fild_for_sum = array('bot', 'Units', 'Human Form Units','Covert Operatives:','Anti-Covert Operatives:'); $u = array(''); foreach ($fild_for_sum as $k) $u = array_merge($u, $c[$k]); for ($i = 1; $i < 12; $i++) { $n = 'unit'.$i; $$n = $u[$i]; } $AT = $c['Attack Turns:'][0]; $unitp = $c['Unit Production:'][0]; echo " unit1 = $unit1, unit2 = $unit2, unit3 = $unit3, unit4 = $unit4, unit5 = $unit5, unit6 = $unit6, unit7 = $unit7, unit8 = $unit8, unit9 = $unit9, unit10 = $unit10, unit11 = $unit11, AT = $AT, unitp = $unitp"; ?>
  13. preg_match_all('/.+ [0-9]+/', $info, $a); <-- find line with numbers in it preg_match_all('/([^0-9]+[0-9]?[^0-9]+) ([0-9 ]+)/', $v, $b); <-- separate text and numbers part $c[$b[1][0]] = explode(' ',$b[2][0]); <-- create array who has text part for key and numbers array for value try to print_r($c);
  14. change foreach ($results as $id => $pts) { echo ' $_' . ordSuffix(++$pos) . ' = ' . $id . '<br />'; } to foreach ($results as $id => $pts) { $name = ' $_' . ordSuffix(++$pos) echo $name. ' = ' . $id . '<br />'; $$name = $id; // or $$name = $pts; }
  15. variable name can't start with number name $1st is not regular you can use $_1st or $position1st
  16. try <?php $info = 'recon Mission Report Under the cover of night, your 1,000,000 Covert Ops sneak into the realm of overburnit . Your Covert Ops move stealthily through the lands of overburnit undetected. They are able to gather many documents recording the status of weapons, army size and preparedness, and fortifications. Unfortunately, in order to avoid detection, they are not able to provide complete information. Your Chief of Intelligence provides you with the information gathered: Army Size: Unit Type Attackers Defenders Untrained bot 0 0 0 Units 0 0 7227 Human Form Units 100000 930000 1478941 Military Stats Strike Action: 0 Defensive Action Huh Covert Action: 60,353,919,808 AntiCovert Action 0 Covert Skill: 22 Covert Operatives: 1050000 Anti-Covert Skill: 21 Anti-Covert Operatives: 0 Attack Turns: 633 Unit Production: 4544'; $find = array('bot', 'Units', 'Human Form troop2a', 'Mercenaries', 'Jaffa Army', 'Super Soldiers', 'Mercenaries', 'Soldier', 'NID Agent', 'Mercenaries', 'Drones', 'Clones', ' ', ','); $replace = array('troop1a', 'troop2a', 'troop3a', 'troop1b', 'troop2b', 'troop3b', 'troop1c', 'troop2c', 'troop3c', 'troop1d', 'troop2d', 'troop3d', ' ', ''); $info = str_replace($find, $replace, $info); preg_match_all('/.+ [0-9]+/', $info, $a); foreach ($a[0] as $k => $v) { preg_match_all('/([^0-9]+[0-9]?[^0-9]+) ([0-9 ]+)/', $v, $b); $c[$b[1][0]] = explode(' ',$b[2][0]); } //print_r($c); $fild_for_sum = array('Strike Action:', 'Covert Skill:', 'troop3a'); $sum =0; foreach ($fild_for_sum as $k) $sum += array_sum($c[$k]); echo 'Sum of fileds ', implode(', ', $fild_for_sum), ' is ', $sum; ?>
  17. function TestParamsShow($group_id=''){ global $db; while (list($key, $val) = each($group_id)) { echo "$val"; $this->sql="SELECT * FROM $this->tb_test_param WHERE group_id ='$val' AND status NOT IN ($this->dead_stat) ORDER BY torder ASC"; if($this->tparams=$db->Execute($this->sql)){ if($this->rec_count=$this->tparams->RecordCount()) { return $this->tparams; // in 1st pass one of this 3 lines return something and } else {return FALSE;} // function end }else {return FALSE;} // newer go to 2nd pass } }
  18. try[ode]<?php $page = basename($_SERVER['SCRIPT_NAME']); $NavBarsExist = false; mysql_select_db($database_connection1, $connection1); $query_rsSANavBars = "SELECT * FROM sanavbars WHERE Type = 'SA' AND FlagStatus = 'A' ORDER BY Name"; $rsSANavBars = mysql_query($query_rsSANavBars, $connection1) or die(mysql_error()); //$row_rsSANavBars = mysql_fetch_assoc($rsSANavBars); $totalRows_rsSANavBars = mysql_num_rows($rsSANavBars); if ($totalRows_rsSANavBars > 0) { while ($row = mysql_fetch_assoc($rsSANavBars)) { $linkurls[] = $row['LinkURL']; // add new array element to $linkurls, an array if ($row['LinkURL'] == $page) { $currentType = $row['Type']; } } // Now, if $currentType is set, then there was a match with $page if($currentType == 'SA'){$c = 'current';}else{$c = 'adminnav';} //$c = $cl ? $c = 'current' : 'adminnav'; echo '<ul class="' .$c . ' one"><li><a href="#?current=one&sub=none"><b>Secure Access</b><!--[if IE 7]><!--></a><!--<![endif]-->'."\n"; echo '<!--[if lte IE 6]><table><tr><td><![endif]-->'."\n"; echo '<ul class="sub" id="navlight">'."\n"; mysql_data_seek($rsSANavBars,0); while ($row_rsSANavBars = mysql_fetch_assoc($rsSANavBars)) { $SANavBarId = $row_rsSANavBars['NavBarId']; mysql_select_db($database_connection1, $connection1); $query_rsSAUserNavBars = "SELECT * FROM sausernavbars WHERE SAUserId = '$SAUserId' AND SANavBarId = '$SANavBarId' AND FlagStatus = 'A'"; $rsSAUserNavBars = mysql_query($query_rsSAUserNavBars, $connection1) or die(mysql_error()); $row_rsSAUserNavBars = mysql_fetch_assoc($rsSAUserNavBars); $totalRows_rsSAUserNavBars = mysql_num_rows($rsSAUserNavBars); // show navbar if user has access to it if ($totalRows_rsSAUserNavBars != 0 || ($totalRows_rsCheckEmpty == 0 && $row_rsSANavBars['NavBarId'] == '112')) { $NavBarsExist = true; ?> <li><a href="<?php echo $row_rsSANavBars['LinkURL'] ?>" class="blackRed"><?php echo $row_rsSANavBars['Name']; ?></a></li> <?php } } } if ($totalRows_rsSANavBars == 0 || !$NavBarsExist) echo '<li><a href="#">not available</a></li>'; ?> </ul> <!--[if lte IE 6]></td></tr></table></a><![endif]--> </li> </ul>
  19. sasa

    Zebra

    try function shade(&$mode) { if ($mode == 0) { echo '</tr><tr style="background-color:#DDDDDD">'; $mode = 1; } else { echo '</tr><tr>'; $mode = 0; } }
  20. when function return something function stop
  21. you say that your file is called employ.php but in your file is line $name = "employment.php";
  22. ups i don't remove line for debug just remove line foreach ($rows as $row)
  23. try <?php echo "</tr>\n"; // printing table rows foreach ($rows as $row) while($row = mysql_fetch_row($result)){ // $row is array... foreach( .. ) puts every element // of $row to $cell variable $count = 0; foreach($row as $cell){ if ($count % 4 == 0) echo '<tr>'; echo "<td>$cell</td>"; $count++; if ($count % 4 == 0) echo '</tr>'; } while ($count % 4 > 0){ $count++; echo '<td> </td>'; } echo "</tr>\n"; } mysql_free_result($result); ?>
  24. try <?php function my_dsort($a, $b){ $a = explode('/',$a); $b = explode('/',$b); if ($a[2] > $b[2]) return 1; if ($a[2] < $b[2]) return -1; if ($a[1] > $b[1]) return 1; if ($a[1] < $b[1]) return -1; if ($a[0] > $b[0]) return 1; if ($a[0] < $b[0]) return -1; return 0; } $dates[0] = '7/17/2007'; $dates[1] = '7/22/2007'; $dates[2] = '6/22/2007'; $dates[3] = '2/22/2008'; shuffle($dates); print_r($dates); usort($dates, 'my_dsort'); print_r($dates); ?>
  25. if you want to remove 1st space use $value = str_replalace(' ', '', implode(';',$ref),1); if you want to remove all spaces use $value = str_replalace(' ', '', implode(';',$ref)); if you want to pass spaces use $value = str_replalace(' ', '+', implode(';',$ref)); sorry i don't see spaces in ref array in first time
×
×
  • 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.