Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. try $x = ''; while($lots_row=mysql_fetch_array($lots_result)){ echo $x, "<td class='boltd'>$lots_row[lot] </td> <td class='boltd'>$lots_row[lot_qty] $bol_row[sau]</td></tr>"; $x = "<tr class'hint'><td class='boltd'> </td> <td class='boltd'> </td> "; }
  2. try <?php function my_level($exp){ $per_lev = 495; $cur_lev = 0; while ($exp >= $cur_lev * $per_lev){ $exp -= $cur_lev * $per_lev; $cur_lev++; } return array('lev' => $cur_lev, 'exp' => $exp, 'for_next_lev' => $cur_lev * $per_lev); } $x = my_level(1500); echo 'you are on level ', $x['lev'], ', ', $x['exp'], ' / ', $x['for_next_lev'] , ' (',round($x['exp'] / $x['for_next_lev'] *100, 2), '%)'; ?>
  3. (before implode)
  4. SELECT title, SUM(count) as count_sum FROM data WHERE id='$id' GROUP BY title
  5. try <?php $options = '<select id="moduleBox" name="selModule" style="align: center;" onChange="insertCode()"> <option value="A">Apple</option> <option value="L">Lemon</option> <option value="P">Peach</option> </select>'; $options = str_replace('value="'.$_REQUEST['value'].'"', 'value="'.$_REQUEST['value'].'" selected="selected" ', $options); echo $options; ?>
  6. <?php if (isset($_POST['username']) and trim($_POST['username'])!='') { $ip=$_SERVER['REMOTE_ADDR']; $name=$_POST['username']; $password=$_POST['password']; $sendinfo=mysql_query("INSERT INTO `dummies`(`User`,`Pass`) VALUES ('$name', '$password')") or die('request - ' . mysql_error()); echo "<h1>Takk. Du kan nĂ¥ logge inn </h1>"; }?> change ' to " in line where you create SQL string
  7. INSERT INTO Completed ( UserID, TopicID, done ) SELECT $UserID, TopicID, 0 FROM Topics
  8. try preg_match_all('/"[^"]*"/', $str, $matches); print_r($matches);
  9. or <?php $page = 44; $total_pages = 50; $start = max(1, min($page - 5, $total_pages - 9)); $end = min($total_pages, max($page + 4, 10)); for ($i = $start; $i <= $end; $i++) { echo $i,' '; } ?>
  10. Ken's code just sum first 3 value in array try to change value for Jan 1st and you can see try $date = 'January 03'; $days = 3; $start = false; $total_price = 0; foreach ($array as $key => $price) { if ($days === 0) break; if ($key === $date || $start){ $total_price += $price; $start = true; $days--; } } echo $total_price;
  11. change while($row = mysql_fetch_array($result)); { ?> to while($row = mysql_fetch_array($result)) { ?> remove ;
  12. try function generateDecks($noofdecks){ $decks = array(); $tmp = array( 1 => "Ace of Hearts", 2 => "2 of Hearts", 3 => "3 of Hearts", 4 => "4 of Hearts", 5 => "5 of Hearts", 6 => "6 of Hearts", 7 => "7 of Hearts", 8 => "8 of Hearts", 9 => "9 of Hearts", 10 => "10 of Hearts", 11 => "Jack of Hearts", 12 => "Oueen of Hearts", 13 => "King of Hearts", 14 => "Ace of Diamonds", 15=> "2 of Diamonds", 16 => "3 of Diamonds", 17 => "4 of Diamonds", 18 => "5 of Diamonds", 19 => "6 of Diamonds", 20 => "7 of Diamonds", 21 => "8 of Diamonds", 22 => "9 of Diamonds", 23 => "10 of Diamonds", 24 => "Jack of Diamonds", 25 => "Oueen of Diamonds", 26 => "King of Diamonds", 27 => "Ace of Spades", 28=> "2 of Spades", 29 => "3 of Spades", 30 => "4 of Spades", 31 => "5 of Spades", 32 => "6 of Spades", 33 => "7 of Spades", 34 => "8 of Spades", 35 => "9 of Spades", 36 => "10 of Spades", 37 => "Jack of Spades", 38 => "Oueen of Spades", 39 => "King of Spades", 40 => "Ace of Spades", 41=> "2 of Spades", 42 => "3 of Spades", 43 => "4 of Spades", 44 => "5 of Spades", 45 => "6 of Spades", 46 => "7 of Spades", 47 => "8 of Spades", 48 => "9 of Spades", 49 => "10 of Spades", 50 => "Jack of Spades", 51 => "Oueen of Spades", 52 => "King of Spades" ); for($i = 0; $i < $noofdecks; $i++){ array_merge($decks,$tmp); } print_r($decks);
  13. insert mysql_data_seek($this->_results, 0); before loop
  14. or <?php $a = rand(1,9); $b = rand(1,9); $x = $a * $b; $arr = array(); for ($i = 1; $i <= sqrt($x); $i++) if (($x % $i == 0) and $x / $i < 10) $arr[] = $i; $c = $arr[rand(0, count($arr)-1)]; $d = $x / $c; echo "$a, $b; $c, $d"; ?>
  15. array_values() function
  16. sorry i mean [tex]\[ \begin{array}{l} S = 1 + 2 + 4 + 8 + 16 + 32 + \ldots \\ 2S = 2\left( {1 + 2 + 4 + 8 + 16 + \ldots } \right) = 2 + 4 + 8 + 16 + 32 \ldots \\ S = 1 + 2S \\ S = - 1 \\ \end{array} \] [/tex]
  17. look this[tex]\[ \begin{array}{l} S = 1 + 2 + 4 + 6 + 8 + \ldots \\ 2S = 2 + 4 + 6 + 16 + \ldots \\ S = 1 + 2S \\ S - 2S = 1 \\ S = - 1 \\ \end{array} \] [/tex]
  18. are you trying this <?php function tester($var){ return $var; } $function = "tester"; $re = $function('sasa'); echo $re; ?>
  19. lcd(a, b) * gcd(a, b) = a * b <?php function gcd($a, $b){ if ($a < 1 or $b < 1 or $a != (int) $a or $b != (int) $b) return false; while ($r = $a % $b){ $a = $b; $b = $r; } return $b; } function lcd($a, $b){ if ($gcd = gcd($a, $b)) return $a * $b / $gcd; else return false; } function lcd_a($array){ if (count($array) == 2) return lcd(array_pop($array), array_pop($array)); $a = array_pop($array); return lcd(lcd_a($array), $a); } echo lcd(5,6) echo lcd_a(array(4,5,6)); ?>
  20. look variable scope variables $hybpred, $sscpred and $pfams don't exist inside function and variable $str don't exist outside
  21. look strftime() function
  22. what you try to do someting like this <?php $test = Array( 3 => Array( 0 => 2, 1 => -2, 2 => 2, 3 => 4), 4 => Array( 0 => 0), 5 => Array( 0 => 1, 1 => 0), 6 => Array( 0 => 0, 1 => 0, 2 => 1), 7 => Array( 0 => 1, 1 => 9), 11 => Array( 0 => 0, 1 => 1) ); foreach ($test as $k1 => $v1){ foreach ($v1 as $k2 => $v2){ $tmp[] = array( 'value' => $v2, 'key1' => $k1, 'key2' => $k2); } } rsort($tmp); print_r($tmp); ?>
  23. try $filename = "scorestore.txt"; $test = file($filename); for ($counter = 0; $counter < count($test); $counter +=1) {$test[$counter] = intval($test[$counter]);}
  24. try <?php $test = array(3,3,0,4,10,1,5,9,10,10); arsort($test); $score = 'x'; $coount = 0; $out = array(); foreach ($test as $k => $v){ $coount++; if($v != $score) { $place = $coount; $score = $v; } $out[$k+1] = $place; } print_r($out); ?>
  25. remove colspan=\"4\" from your echo
×
×
  • 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.