Jump to content

marcus

Members
  • Posts

    1,842
  • Joined

  • Last visited

Posts posted by marcus

  1. This isn't a PHP problem. Avoid using the same ID multiple times. You have "#image_rotate" used twice, jQuery is going to confuse itself. If you want to use a layer multiple times make it a class. I would suggest renaming both IDs to something like.

     

    <ul id="gallery1">

     

    and

     

    <ul id="gallery2">

     

    Then you should be able to use

    $('#gallery1, #gallery2')

    in your jQuery script.

  2. You don't have a name to your submit button.

     

    <input type="submit" name="Submit" value="Query" />

     

    You should also look into using a switch statement.

     

    switch($_POST['query']){
        case 'add_status':
            // code
        break;
    
        // etc
    
        default:
            // if no option is selected
    }

  3. Functions are public without any cast.

     

    class A {
        public $user;
        
        public function __construct(){
            $this->user = 'apple';
        }
        
        function getApple(){
            return $this->user;
        }
    }
    
    class B {
        public $user;
        
        public function __construct(){
            $a = new A();
            $this->user = 'b' . $a->getApple();
        }
        
        function getApple(){
            return $this->user;
        }
    }
    
    $b = new B;
    echo $b->getApple();

     

    This code would return bapple.

     

    If the getApple() method in A was private, B would not be able to access A's getApple() method. However, if A's getApple() method was protected, and class B extends A, then you would be able to access A's getApple() method.

  4. function findIndex($array, $value){
         if(count($array) > 0){
              $i = 0;
              foreach($array AS $val){
                   // check if val is equal to value, if it is return $i
                   // increment $i
              }
         }
    
         return -1;
    }

     

    Alternatively you could use a for loop

     

    $count = count($array);
    for($i = 0; $i < $count; $i++){
         // if array position at $i equals your value, return $i
    }

     

    -1 is used to indicate the value was never found. So when using the function

     

    $index = findIndex($array, $value);
    if($index < 0){
    // not found
    }else {
    // found at $index
    }

  5. Well for one... get rid of the selected in the first option value that says "Please select..."

     

    while($rowt = mysql_fetch_assoc($rst)){
        $sel = ($_SESSION['type_of_work_id1'] == $rowt['type_of_work_id']) ? " SELECTED" : ""; // $rowt['type_of_work_id'] is what i'm assuming, change if not
        // rest of code
    }

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