Jump to content

gurroa

Members
  • Posts

    87
  • Joined

  • Last visited

    Never

Posts posted by gurroa

  1.   // this function sort double array by given key name
      function SortArrayByValue($ar, $keyname, $desc = false) {
        if (!is_array($ar) || empty($keyname)) return $ar;
        $arsort = array();
        reset($ar);
        while(list($key, $rad) = each($ar)) {
          $val = $rad[$keyname];
          $v   = 1;
          while(isset($arsort[$val])) $val = $rad[$keyname].' '.$v++;
          $arsort[$val] = $key;
        }
        if ($desc) krsort($arsort);
        else ksort($arsort);
    
        reset($arsort);
        
        $retar = array();
        while(list(,$key) = each($arsort))
          $retar[$key] = $ar[$key];
        
        return $retar;
      }
    
      $arevents = array();
      while($row = mysql_fetch_array($result)) {
        $startdays = array($row['Startdate1'], $row['Startdate2'], $row['Startdate3']);
        if (!empty($startdays[0])) {
          $row['Startdate'] = $startdays[0];
          $row['Sortway'] = $row['Startdate'].' '.$row['Time'];
          $arevents[] = $row;
        }
        if (!empty($startdays[1])) {
          $row['Startdate'] = $startdays[1];
          $row['Sortway'] = $row['Startdate'].' '.$row['Time'];
          $arevents[] = $row;
        }
        if (!empty($startdays[2])) {
          $row['Startdate'] = $startdays[2];
          $row['Sortway'] = $row['Startdate'].' '.$row['Time'];
          $arevents[] = $row;
        }
      }
      if (count($arevents) > 0) 
        $arevents = SortArrayByValue($arevents, 'Sortway', false);
    
      //listevents
      reset($arevents);
      while(list(,$row) = each($arevents)) 
         echo $row['Startdate'].' '.$row['Title'].'<br />';
    

     

  2. Comparing is done via == sign not =.

    function validatei_agree(fld) {
      if (fld.checked == false) { // if (!fld.checked)
        delete fld;
        return "You must agree to the Terms and Conditions";
      }
      delete fld;
      return "";
    }
    

  3. I would use stripos and substr.

    As long as the data are stored in the simple table...

      $contentofsite = '<html.....</html>';
    
      function GetCont($search, $htmldata) {
        $_table_start = ($i = stripos($htmldata, '<td><b>'.$search)) !== false ? stripos($htmldata, '<table', $i-100) : -1;
        if ($_table_start > 0) 
          return ($i = stripos($htmldata, '</table>', $i+6)) !== false ? substr($htmldata, $_table_start, $i-$_table_start+ : 'Not found';
    
        return 'Not found';
      }
      
      echo GetCont('Earnings Est', $contentofsite);
    

  4. If you don't want to use javascript,

    you can use only two frames and the second one containing <iframe>.

    Than you just submit your form fromt the first one into the second frame.

    //file1.html
    <frameset rows="120,*">
      <frame name="formframe" src="form.htm">
      <frame name="resultsframe" src="res.php">
    </frameset>
    
    //form.htm
    <form target="resframe" method="post">
    <input type="submit" value="send">
    </form>
    
    //res.php
    <body>
    <iframe src="links.html" style="position: absolute; right: 0; height: 100%; width: 200px;..whatever.."></iframe>
    <?php /* form results... */ ?>
    </body>
    

    If you don't want to use <iframe> you can achieve similar results by using two framesets... (but you will have to resend form content through the second frameset).

  5. <img src="mouse.gif" 
      onmouseover="document.getElementById('ImageToChange').src='images/nav/2-on.gif';" 
      onmouseout="document.getElementById('ImageToChange').src='images/nav/2.gif';"
    ><br />
    ...
    <img src="images/nav/2.gif" id="ImageToChange">
    

  6. Just prepare form with hidden fields and submit it just after opening new window.

    You just have to set the same target as is the new window's name.

    <html>
    <script>
      function OpenNewWindow() {
        window.open('about:blank', 'NewWindow', '...');
      }
    </script>
    <body>
    <form name="MyHiddenForm" method="post" action="test3.php" target="NewWindow">
    <input type="hidden" name="var1" value="val...">
    <input type="hidden" name="var2" value="val...">
    </form>
    <button type="button" onclick="OpenNewWindow(); document.MyHiddenForm.submit();">Open new window</button>
    </body>
    </html>
    

  7. Try it this way.
    <?php
      // php code is here
      require "config.php";
    
      $query = mysql_query("SELECT COUNT(page_title) AS cnt FROM pages") or die ("Could not query because: ".mysql_error());
      $row = mysql_fetch_array($query);
      $count = isset($row['cnt']) ? $row['cnt'] : 0;
    
      if ($count > 707185109) {
    ?>
    for (var i = 707185109; i < <?php echo $count; ?>; ++i) 
      document.write(i);
    delete i;
    <? 
      }
    ?>
    

  8.   function ReturnRandomFromArray(&$arr) {  
        $randar = array();
        reset($arr);
        while(list(,$hod)=each($arr)) $randar[] = $hod;
    
        $randar = array_values($randar);
        $c = count($randar);
        if ($c > 1) {
          --$c;
          $r = rand(0,$c);
          while(empty($randar[$r])) $r = rand(0,$c);
          return $randar[$r];
        } 
        elseif ($c == 1) 
          return $randar[0];
          
        else
          return '';
      }
    
      // you will probably fill this array from your database
      $ardat = array( 'tile unique id', 'tile unique id'....);
    
      $armap = array();
    
      for ($x = 0; $x < 16; ++$x) {
        $xx = $x * 16;
        for ($y = 0; $y < 16; ++$y)
          $armap[$xx + $y] = ReturnRandomFromArray($ardat);
      }
      
    

     

  9. If you send form using the get method you should not add variables into the action url.

    Try moving variables from action into <input type="hidden" type fields.

      echo "</table></form><form method='get' action='update.php'>";
      echo '<input type="hidden" name="c" value="'.$c.'">';
      echo '<input type="hidden" name="r" value="'.$r.'">';
      echo '<input type="hidden" name="t" value="'.$t.'">';
      echo $c." ".$r."<input type=submit name=update value=Update /></form><br />";
    

     

    Warning appeard because php converts empty variable into 0 (if you deal with such variable in any math operation).

×
×
  • 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.