Jump to content

gurroa

Members
  • Posts

    87
  • Joined

  • Last visited

    Never

Posts posted by gurroa

  1. I'm using this and later when proceeding form check wheter is foo not empty.

    It's because IE users are still able to select disabled option.

    <select name="foo" onchange="if(this.value=='')this.value=1;">
    <option value="1">Option 1
    <option disabled value="" style="color: gray">Option 2
    <option value="2">Option 3
    </select>
    

  2. You can let user download your file through the php script.

    <?php
      // download.php
    
      //...
      // first check wheter user can download this file once more time
      // you can save download times into your db.
    
      if ($user_can_download) {
        // if it is a zip file
        // you can store your file somewhere where users can reach it 
        $file = './myfilestorage/file_01.zip';
    
        Header('Content-type: application/x-zip-compressed');
        Header('Content-Disposition: attachment; filename="file_01.zip"');
        Header('Content-length: '.filesize($file));
    
        readfile($file);
        Exit;
      } else {
        //... normal output telling user you can't download this file anymore
      }
    

  3. If you don't need id values.

    Or you can use style.zIndex as a temporary storage.

    <script type="text/javascript">
    function SwapValues(frst, sec) {
      var val = frst.value;
      frst.value = sec.id;
      sec.value = val;
      delete frst; delete sec; delete val;
    }
    function updateForm (which) {
      if (document.rankem.a != which && document.rankem.a.value == which.value) SwapValues(document.rankem.a, which);
      else
      if (document.rankem.b != which && document.rankem.b.value == which.value) SwapValues(document.rankem.b, which);
      else
      if (document.rankem.c != which && document.rankem.c.value == which.value) SwapValues(document.rankem.c, which);
      else
      if (document.rankem.d != which && document.rankem.d.value == which.value) SwapValues(document.rankem.d, which);
    
      delete which;
    }
    </script>
    <form id="rankem" name="rankem" method="post" action="">
      <p>
        <input name="a" type="text" id="0" size="3" value="1" onfocus="this.id=this.value" onchange="updateForm(this);" />
      </p>
      <p>
        <input name="b" type="text" id="0" size="3" value="2" onfocus="this.id=this.value" onchange="updateForm(this);" />
      </p>
      <p>
        <input name="c" type="text" id="0" size="3" value="3" onfocus="this.id=this.value" onchange="updateForm(this);" />
      </p>
      <p>
        <input name="d" type="text" id="0" size="3" value="4" onfocus="this.id=this.value" onchange="updateForm(this);" />
      </p>
    </form>
    

  4. I think all you need to add is few if statements

    //Get Sire
      if (is_numeric($row['SireID'])) {
       $SireQ = $sql . $row['SireID']; 
       ....  
    //Get PatGrandSire info
        if (is_numeric($SireRow['SireID'])) {
          $PatGrandSireQ = $sql . $SireRow['SireID'];
          ....
       //Get Pat1GGrandSire info
          if (is_numeric($PatGrandSireRow['SireID'])) {
             $Pat1GGrandSireQ = $sql . $PatGrandSireRow['SireID'];
             ....
    
          }//PatGrandSireRow[sireID]
    
        }//SireRow[sireID]
    
      }//row[sireID]
    
    ///////////
    
    // in outputting data you just check wheter is your array set
    <small>
    Sire
    ".(isset($SireRow) ? $SireRow['RegName'] : '')."</small>
    

  5. You can add some tests messages just to see what is happining in your script.

    <?php
    
      $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
      echo 'Action: '.$action.'<br />';
      if (($action == 'edit') && isset($HTTP_GET_VARS['oID'])) {
        $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
        echo 'oID: '.$oID.'<br />';
    
        $orders_query = tep_db_query("select orders_id from holding_orders where orders_id = '" . (int)$oID . "'");
        $order_exists = true;
        if (!tep_db_num_rows($orders_query)) {
          echo 'Error, order doesn\' exists.<br />';
          $order_exists = false;
          $messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST, $oID), 'error');
        } else {
          echo 'Order does exists!<br />';
        }
      }
      echo 'orderheld.php';
      include(DIR_WS_CLASSES . 'orderheld.php');
      Exit;
    ?>
    

     

    Now if you run mainpage with parametrs mainpage.php?action=edit&oID=1 you should see

    Action: edit<br />
    oID: 1<br />
    Order does exists!<br />
    orderheld.php
    

     

    If you don't than you can see there is something wrong with this part.

    But if you do - delete Exit; command and put more tests further more and test again.

     

     

    My tip is that you are missing some important includes. With tep_ etc. functions and database connections.

  6. <?php
      //overview
      include('database.php');
      $query = "SELECT * FROM polls1 ORDER BY id DESC LIMIT 1";
      $rez = mysql_query($query);
      $row = mysql_fetch_array($rez);
      $id=$row['id']; 
      print('<center>
        <form action="'.$_SERVER['PHP_SELF'].'" method="POST">
        <br>"'.$row['quest'].'"<br />
        <br>"'.$row['a'].'"<input type="checkbox" name="a"><br />
        <br>"'.$row['b'].'"<input type="checkbox" name="b"><br />
        <br>"'.$row['c'].'"<input type="checkbox" name="c"><br />
        <br>"'.$row['d'].'"<input type="checkbox" name="d"><br />
        <br />
        <input type="submit" name="action" value="Send!">
        </form>
        </center>
      ');
       
      // you can use this code to write one result from radio checks too.
      // because in that case only one value will be filled
      if(isset($_POST['action']))
      {
        $a = empty($_POST['a']) ? 0 : 1;
        $b = empty($_POST['b']) ? 0 : 1;
        $c = empty($_POST['c']) ? 0 : 1;
        $d = empty($_POST['d']) ? 0 : 1;
        
        if ($a + $b + $c + $d > 0) {
          $query = "UPDATE results2 SET a = a + %d, b = b + %d, c = c + %d, d = d + %d WHERE id = %d";
          mysql_query(sprintf($query, 
             $a, $b, $c, $d, $id
          ));
        }
      }
      
      print('<a href=results.php>Results</a>');
    ?>
    

  7. Shouldn't you be using $SireGGrandSireRow in the last two levels?

    And from middle of your code you are writing data into pedigree array under the same key values.

    if ($SireGGrandSireR) {
      $SireGGrandSireRow = mysql_fetch_array ($SireGrandSireR, MYSQL_ASSOC);
      $pedigree['DamGrandGrand'] = $SireGGrandSireRow['RegName'];
      $pedigree['DamGrandGrandSireID'] = $SireGGrandSireRow['SireID'];
      $pedigree['DamGrandGrandDamID'] =$SireGGrandSireRow['DamID'];
      $message.= "<td class=shade>GrandGrandDam - ".$SireGGrandSireRow ['RegName']."</td>";   
    }
    

     

    I would use other way to get those data.

    Split this task into two parts - get the data, output data.

      $pedigree = array();
      
      $sql    = "SELECT RegName, SireID, DamID FROM Pedigrees WHERE ID in (%s)";
      
      $result = mysql_query(sprintf($sql, $values['ID']));
    
      if ($result) {
        $row = mysql_fetch_assoc($result);
        $pedigree[$row['ID']] = $row;
        
        $newIDs = array();
        if (!empty($row['SireID'])) $newIDs[] = $row['SireID'];
        if (!empty($row['DamID'])) $newIDs[]  = $row['DamID'];
        
        $level = 1;
        $maxlevel = 3;
        while (count($newIDs) > 0 && $level <= $maxlevel) {
          
          // select all current anc.
          $newIDs = array();
          $ancres = mysql_query(sprintf($sql, Implode(", ", $newIDs)));
          if ($ancres) {
            while ($row = mysql_fetch_assoc($ancres)) {
              $pedigree[$row['ID']] = $row;
              if (!empty($row['SireID'])) $newIDs[] = $row['SireID'];
              if (!empty($row['DamID'])) $newIDs[]  = $row['DamID'];
            }
          }
          
          ++$level;
        }
    
        $row = $pedigree[$values['ID']];
        // prepare empty output assoc array with first Reg value.
        $outped = array('Reg' => $row['RegName'], 
                'Sire' => '', 'Dam' => '', 'SireSire' => '', 'SireDam' => '', 'DamSire' => '', 'DamDam' => ''
                ....
                );
        if (!empty($row['SireID']) && isset($pedigree[$row['SireID']])) {
          $sirerow = $pedigree[$row['SireID']];
          $outped['Sire'] = $sirerow['RegName'];
          
          if (!empty($sirerow['SireID']) && isset($pedigree[$sirerow['SireID'])) {
            $SireSire = $pedigree[$sirerow['SireID']];
            $outped['SireSire'] = $SireSire['RegName'];
            if (!empty(......
              // another anc.
            }          
          }
          if (!empty($sirerow['DamID']) && isset($pedigree[$sirerow['DamID']])) {
            $SireDam = $pedigree[$sirerow['DamID']];
            $outped['SireDam'] = $SireDam['RegName'];
            if (!empty(...
              // another anc.
            }
          }  
          
        } 
        
        if (!empty($row['DamID']) && isset($pedigree[$row['SireID']])) {
          $damrow = $pedigree[$row['SireID']];
          $outped['Dam'] = $damrow['RegName'];
          
          if (!empty($damrow['SireID']) && isset($pedigree[$damrow['SireID']])) {
            $DamSire = $pedigree[$damrow['SireID']];
            $outped['DamSire'] = $DamSire['RegName'];
            if (!empty(....
              // another anc.
            }
          }
          
          ....
        }
      
        // output data
        $message  = "<table cellspacing=1 cellpading=1><tr><td colspan=4 align=center class=blackshade>Pedigree Table</td></tr>";
        $message .= "<tr><td colspan=8 class=shade>RegName - ".$outped['Reg']."</td></tr>";
        $message .= "<tr><td rowspan=4 class=shade>Sire - ".$outped['Sire']."</td><td rowspan=4 class=shade>Dam - ".$outped['Dam']."</td></td>";
        $message .= "<tr><td rowspan=2 class=shade>SireSire - ".$outped['SireSire']."</td>".
                        "<td rowspan=2 class=shade>SireDam - ".$outped['SireDam']."</td>".
                        "<td rowspan=2 class=shade>DamSire - ".$outped['DamDam']."</td>".
                        "<td rowspan=2 class=shade>DamDam - ".$outped['DamDam']."</td>".
                        "</tr>";
        ....
    
      }
    

  8. Try this

      if (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
        // you should always control what users send you via your variables.
        // someone "clever" could open [url]ordersholding.php?delete=1 or (1 = 1)[/url] and delete your whole database
        $delete = $_GET['delete']*1;
        tep_db_query("delete from " . TABLE_HOLDING_ORDERS . " where orders_id = " . $delete . "");
        tep_db_query("delete from " . TABLE_HOLDING_ORDERS_PRODUCTS . " where orders_id = " . $delete . "");
        tep_db_query("delete from " . TABLE_HOLDING_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = " . $delete . "");
        tep_db_query("delete from " . TABLE_HOLDING_ORDERS_TOTAL . " where orders_id = " . $delete . "");
      }
    

     

  9. You are filling $tourn varibale but testing $tour variable.

    while($row = mysql_fetch_array($result,MYSQL_NUM)) {
      $tourn = $row[2]; //!
    }
    if (($type == 'course') && ($tourn == 'INTERMEDIATE')) {
        $sendto = "intermediatecourses@cycleyorkshire.co.uk";
    } elseif (($type == 'course') && ($tourn == 'BEGGINNER')) {
        $sendto = "begginercourses@cycleyorkshire.co.uk";
    } elseif ($type == 'tour') {
        $sendto = "tours@cycleyorkshire.co.uk";
    } else {
        // Unknown tour type
        return false;
    }
    echo $sendto;
    

     

  10. ;)

      while( ($dest = 4) && !isset($b) && (($b = ($max = $dest * ($i = $j = 1) + 1) < 0) == false) ) 
        while ((!$b && $i < ($max + ($j = 0))) || ($b && ($i-- > 0 + ($j = 0))) )
          while( (($j < $i ? ++$j : $max + (!$b ? ++$i : (5 + $i)) ) <= $max && print($j))  
              || !print("<br />".(($b = $b || ($i == $max)) ? (($i = ($i == $max ? $i - 1 : $i)) ? '' : '') : ''))
          ) ;
    

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