Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 27 of 27
  1. #16
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,237
    Thanks
    12
    Thanked 340 Times in 336 Posts
    Quote Originally Posted by phyra_x99 View Post
    where should i assign that code?
    where the variables are.


    Quote Originally Posted by phyra_x99 View Post
    and what are they for?
    debugging.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  2. #17
    New Coder
    Join Date
    Jun 2013
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Code:
    <?php
    	$db = new mysqli('localhost', 'root', 'root', 'elitedb') or die("An error occured. " .mysql_error());
    	$query = "select categoryid, categoryname from tcategory";
    	$result = $db->query($query);
    
    	while($row = $result->fetch_assoc()){
    		$categories[] = array("id" => $row['categoryid'], "val" => $row['categoryname']);
    	}
    
    	$query = "select subcategoryid, subcategoryname, parentcategoryid from tsubcategory";
    	$result = $db->query($query);
    
    	while($row = $result->fetch_assoc()){
    		$subcategories[$row['parentcategoryid']][] = array("id" => $row['subcategoryid'], "val" => $row['subcategoryname']);
    	}
    
    	$jsonCategories = json_encode($categories);
    	$jsonSubcategories = json_encode($subcategories);
    	
    	$query = "select carvendorid, carvendorname from tcarvendor";
    	$result = $db->query($query);
    	
    	while($row = $result->fetch_assoc()){
    		$carvendor[] = array("id" => $row['carvendorid'], "val" => $row['carvendorname']);
    	}
    	
    	$query = "select carid, carname, carvendorid from tcar";
    	$result = $db->query($query);
    	
    	while($row = $result->fetch_assoc()){
    		$car[$row['carvendorid']][] = array("id" => $row['carid'], "val" => $row['carname']);
    	}
    	
    	$jsonCarvendor = json_encode($carvendor);
    	$jsonCar = json_encode($car);
    	
    	/*================*/
    	
    	$query = "select tcaryear.yearid, tyear.year, tcaryear.carid from tcaryear inner join tyear on tyear.yearid = tcaryear.yearid";
    	$result = $db->query($query);
    	
    	while($row = $result->fetch_assoc()){
    		$year[$row['tcaryear.carid']][] = array("id" => $row['tcaryear.yearid'], "val" => $row['tyear.year']);
    	}
    
    	var_dump($row);
            var_dump($year);
    
    	$jsonYear = json_encode($year);
    ?>
    right there? or before $query?

  3. #18
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,237
    Thanks
    12
    Thanked 340 Times in 336 Posts
    this place ’s ok.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  4. #19
    New Coder
    Join Date
    Jun 2013
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    this place ’s ok.
    ummm... this is what i got..

    Code:
    
    NULL
    array(1) {
      [""]=>
      array(42) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [3]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [4]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [5]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [6]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [7]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [8]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [9]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [10]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [11]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [12]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [13]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [14]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [15]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [16]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [17]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [18]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [19]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [20]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [21]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [22]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [23]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [24]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [25]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [26]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [27]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [28]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [29]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [30]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [31]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [32]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [33]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [34]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [35]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [36]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [37]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [38]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [39]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [40]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [41]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    
    <html>
    <head>
    	<script type='text/javascript'>
            var categories = [{"id":"1","val":"accessories"},{"id":"2","val":"bungkus jok"},{"id":"3","val":"lampu"}]; 
    var subcategories = {"1":[{"id":"1","val":"outter door"},{"id":"2","val":"garnish lampu"}],"2":[{"id":"3","val":"foglamp"},{"id":"4","val":"led"},{"id":"7","val":"2 baris"},{"id":"8","val":"3 baris"}],"3":[{"id":"5","val":"led"},{"id":"6","val":"foglamp"}]}; 
    var carvendor = [{"id":"1","val":"honda"},{"id":"2","val":"toyota"},{"id":"3","val":"nissan"},{"id":"4","val":"daihatsu"},{"id":"5","val":"kia"},{"id":"6","val":"bmw"},{"id":"7","val":"mercedes benz"},{"id":"8","val":"audi"}]; 
    var car = {"1":[{"id":"1","val":"jazz"},{"id":"2","val":"brio"},{"id":"3","val":"accord"},{"id":"4","val":"cr-z"}],"2":[{"id":"5","val":"kijang"},{"id":"6","val":"innova"},{"id":"7","val":"avanza"},{"id":"8","val":"corolla"},{"id":"9","val":"vios"}],"3":[{"id":"10","val":"juke"},{"id":"11","val":"march"},{"id":"12","val":"serena"}],"4":[{"id":"13","val":"xenia"}],"5":[{"id":"14","val":"carnival"},{"id":"15","val":"carens"},{"id":"16","val":"picanto"},{"id":"17","val":"rio"},{"id":"18","val":"sportage"}],"6":[{"id":"19","val":"320i"},{"id":"20","val":"323i"},{"id":"21","val":"520"},{"id":"22","val":"720"}],"7":[{"id":"23","val":"c200"},{"id":"24","val":"c250"},{"id":"25","val":"c300"},{"id":"26","val":"e200"},{"id":"27","val":"e250"},{"id":"28","val":"e300"}]}; 
    var year = {"":[{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null},{"id":null,"val":null}]}; 
    		
    		window.onload = function(){
    			loadCategories();
    			loadCarvendor();
    		}
    		
            function loadCategories(){
                var categorySelect = document.getElementById("category");
                categorySelect.onchange = updateSubCategories;
                for(var a = 0; a < categories.length; a++){
                    categorySelect.options[a] = new Option(categories[a].val, categories[a].id);          
                }
            }
            function updateSubCategories(){
                var categorySelect = this;
                var categoryid = this.value;
                var subcategorySelect = document.getElementById("subcategory");
                subcategorySelect.options.length = 0;
                for(var a = 0; a < subcategories[categoryid].length; a++){
                    subcategorySelect.options[a] = new Option(subcategories[categoryid][a].val, subcategories[categoryid][a].id);
                }
            }
    		function loadCarvendor(){
    			var carvendorSelect = document.getElementById("carvendor");
    			carvendorSelect.onchange = updateCar;
    			for(var b = 0; b < carvendor.length; b++){
    				carvendorSelect.options[b] = new Option(carvendor[b].val, carvendor[b].id);
    			}
    		}
    		function updateCar(){
    			var carvendorSelect = this;
    			var carvendorid = this.value;
    			var carSelect = document.getElementById("car");
    			carSelect.onchange = updateYear;
    			carSelect.options.length = 0;
    			for(var b = 0; b < car[carvendorid].length; b++){
    				carSelect.options[b] = new Option(car[carvendorid][b].val, car[carvendorid][b].id);
    			}
    		}
    		function updateYear(){
    			var carSelect = this;
    			var carid = this.value;
    			var yearSelect = document.getElementById("year");
    			yearSelect.options.length = 0;
    			for(var b = 0; b < year[carid].length; b++){
    				yearSelect.options[b] = new Option(year[carid][b].val, year[carid][b].id);
    			}
    		}
        </script>
    </head>
    <body>
        <form id="addstock" method="post" action="index.php?module=prosesAddStock">
            <table border="1">
                <tr>
                    <td> Code Barang </td>
                    <td> <input type="text" name="codebarang" size="10"> </td>
                </tr>
                <tr>
                    <td> Nama Barang </td>
                    <td> <input type="text" name="namabarang" size="20"> <input type="hidden" name="categoryid" value="  "> </td>
                </tr>
                <tr>
                    <td> Car Vendor Name </td>
                    <td> <select name="carvendorname" id="carvendor"> </select> </td>
                </tr>
                <tr>
                    <td> Car Name </td>
                    <td> <select name="carname" id="car"> </select> </td>
                </tr>
                <tr>
                    <td> Car Year </td>
                    <td> <select name="caryear" id="year"> </select> </td>
                </tr>
                <tr>
                    <td> Category </td>
                    <td> <select name="category" id="category"> </select> </td>
                </tr>
                <tr>
                    <td> Sub-Category </td>
                    <td> <select name="subcategory" id="subcategory"> </select> </td>
                </tr>
                <tr>
                    <td> Supplier </td>
                    <td>
                        <select name="supplierid"></select>                </td>
                </tr>
                <tr>
                    <td> Quantity </td>
                    <td> <input type="text" name="quantity" size="6"> </td>
                </tr>
                <tr>
                    <td> Satuan </td>
                    <td>
                        <select name="satuanid"></select>                </td>
                </tr>
                <tr>
                    <td> Code Harga </td>
                    <td> <input type="text" name="codeharga" size="10"> </td>
                </tr>
                <tr>
                    <td> Harga Jual/Satuan </td>
                    <td> <input type="text" name="hargajualsatuan" size="10"> </td>
                </tr>
                <tr>
                    <td> </td>
                    <td> <input type="submit" name="OK" value="OK"> <input type="reset" name="reset" value="Reset"> </td>
                </tr>
            </table>
        </form>
    </body>
    </html>

  5. #20
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,237
    Thanks
    12
    Thanked 340 Times in 336 Posts
    just for the records, put it inside the while loop.

    note: new mysqli() or die() wont’t work. in case you have no connection you will still get an mysqli object. you explicitly need to test with myqli->connect_error
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  6. #21
    New Coder
    Join Date
    Jun 2013
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    just for the records, put it inside the while loop.

    note: new mysqli() or die() wont’t work. in case you have no connection you will still get an mysqli object. you explicitly need to test with myqli->connect_error
    you mean put the var_dump($row) and var_dump($year) inside the while loop?

  7. #22
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,237
    Thanks
    12
    Thanked 340 Times in 336 Posts
    Quote Originally Posted by phyra_x99 View Post
    you mean put the var_dump($row) and var_dump($year) inside the while loop?
    not necessarily $year, but $row (how else will you know what is passed in the assignment process?)
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  8. #23
    New Coder
    Join Date
    Jun 2013
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    not necessarily $year, but $row (how else will you know what is passed in the assignment process?)
    this is what i got.. it is kind of different with the previous one.. the code seems work but most of the arrays are null.

    Code:
    array(3) {
      ["yearid"]=>
      string(1) "1"
      ["year"]=>
      string(4) "2000"
      ["carid"]=>
      string(1) "3"
    }
    array(1) {
      [""]=>
      array(1) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(3) {
      ["yearid"]=>
      string(1) "1"
      ["year"]=>
      string(4) "2000"
      ["carid"]=>
      string(1) "4"
    }
    array(1) {
      [""]=>
      array(2) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(3) {
      ["yearid"]=>
      string(1) "1"
      ["year"]=>
      string(4) "2000"
      ["carid"]=>
      string(1) "5"
    }
    array(1) {
      [""]=>
      array(3) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(3) {
      ["yearid"]=>
      string(1) "1"
      ["year"]=>
      string(4) "2000"
      ["carid"]=>
      string(1) "6"
    }
    array(1) {
      [""]=>
      array(4) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [3]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(3) {
      ["yearid"]=>
      string(1) "1"
      ["year"]=>
      string(4) "2000"
      ["carid"]=>
      string(1) "7"
    }
    array(1) {
      [""]=>
      array(5) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [3]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [4]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(3) {
      ["yearid"]=>
      string(1) "1"
      ["year"]=>
      string(4) "2000"
      ["carid"]=>
      string(1) "8"
    }
    array(1) {
      [""]=>
      array(6) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [3]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [4]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [5]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(3) {
      ["yearid"]=>
      string(1) "1"
      ["year"]=>
      string(4) "2000"
      ["carid"]=>
      string(1) "9"
    }
    array(1) {
      [""]=>
      array(7) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [3]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [4]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [5]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [6]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(3) {
      ["yearid"]=>
      string(1) "1"
      ["year"]=>
      string(4) "2000"
      ["carid"]=>
      string(2) "10"
    }
    array(1) {
      [""]=>
      array(8) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [3]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [4]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [5]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [6]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [7]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(3) {
      ["yearid"]=>
      string(1) "1"
      ["year"]=>
      string(4) "2000"
      ["carid"]=>
      string(2) "11"
    }
    array(1) {
      [""]=>
      array(9) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [3]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [4]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [5]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [6]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [7]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [8]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(3) {
      ["yearid"]=>
      string(1) "1"
      ["year"]=>
      string(4) "2000"
      ["carid"]=>
      string(2) "12"
    }
    array(1) {
      [""]=>
      array(10) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [3]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [4]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [5]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [6]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [7]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [8]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [9]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(3) {
      ["yearid"]=>
      string(1) "1"
      ["year"]=>
      string(4) "2000"
      ["carid"]=>
      string(2) "13"
    }
    array(1) {
      [""]=>
      array(11) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [3]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [4]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [5]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [6]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [7]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [8]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [9]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [10]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(3) {
      ["yearid"]=>
      string(1) "1"
      ["year"]=>
      string(4) "2000"
      ["carid"]=>
      string(2) "14"
    }
    array(1) {
      [""]=>
      array(12) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [3]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [4]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [5]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [6]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [7]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [8]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [9]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [10]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [11]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(3) {
      ["yearid"]=>
      string(1) "1"
      ["year"]=>
      string(4) "2000"
      ["carid"]=>
      string(2) "15"
    }
    array(1) {
      [""]=>
      array(13) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [3]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [4]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [5]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [6]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [7]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [8]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [9]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [10]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [11]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [12]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(3) {
      ["yearid"]=>
      string(1) "1"
      ["year"]=>
      string(4) "2000"
      ["carid"]=>
      string(2) "16"
    }
    array(1) {
      [""]=>
      array(14) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [3]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [4]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [5]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [6]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [7]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [8]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [9]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [10]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [11]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [12]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [13]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(3) {
      ["yearid"]=>
      string(1) "1"
      ["year"]=>
      string(4) "2000"
      ["carid"]=>
      string(2) "17"
    }
    array(1) {
      [""]=>
      array(15) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [3]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [4]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [5]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [6]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [7]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [8]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [9]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [10]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [11]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [12]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [13]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [14]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(3) {
      ["yearid"]=>
      string(1) "1"
      ["year"]=>
      string(4) "2000"
      ["carid"]=>
      string(2) "18"
    }
    array(1) {
      [""]=>
      array(16) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [3]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [4]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [5]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [6]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [7]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [8]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [9]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [10]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [11]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [12]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [13]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [14]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [15]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    it seems that the code failed to fetch the result to the $year because the $query works fine and $row is existed with the result of the $query.

    P.S
    i cut the codes because it is way to long.
    Last edited by phyra_x99; 07-17-2013 at 08:51 AM.

  9. #24
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,237
    Thanks
    12
    Thanked 340 Times in 336 Posts
    it seems that the code failed to fetch the result
    nope.

    have a close look at the indices:
    Code:
    // $year
    $year[$row['tcaryear.carid']][] = array(
        "id"   => $row['tcaryear.yearid'], 
        "val"  => $row['tyear.year']
    );
    Code:
    // $row
    array(3) {
      ["yearid"] =>  string(1) "1"
      ["year"]   =>  string(4) "2000"
      ["carid"]  =>  string(1) "3"
    }
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  10. #25
    New Coder
    Join Date
    Jun 2013
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    nope.

    have a close look at the indices:
    Code:
    // $year
    $year[$row['tcaryear.carid']][] = array(
        "id"   => $row['tcaryear.yearid'], 
        "val"  => $row['tyear.year']
    );
    Code:
    // $row
    array(3) {
      ["yearid"] =>  string(1) "1"
      ["year"]   =>  string(4) "2000"
      ["carid"]  =>  string(1) "3"
    }
    so what's wrong with these things?

    this is what i got when i var_dump($year)
    Code:
    array(1) {
      [""]=>
      array(1) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(1) {
      [""]=>
      array(2) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(1) {
      [""]=>
      array(3) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }
    array(1) {
      [""]=>
      array(4) {
        [0]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [1]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [2]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
        [3]=>
        array(2) {
          ["id"]=>
          NULL
          ["val"]=>
          NULL
        }
      }
    }

  11. #26
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,237
    Thanks
    12
    Thanked 340 Times in 336 Posts
    let’s add some colour:
    Code:
    // $year
    $year[$row['tcaryear.carid']][] = array(
        "id"   => $row['tcaryear.yearid'], 
        "val"  => $row['tyear.year']
    );
    Code:
    // $row
    array(3) {
      ["yearid"] =>  string(1) "1"
      ["year"]   =>  string(4) "2000"
      ["carid"]  =>  string(1) "3"
    }
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  12. Users who have thanked Dormilich for this post:

    phyra_x99 (07-17-2013)

  13. #27
    New Coder
    Join Date
    Jun 2013
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    let’s add some colour:
    Code:
    // $year
    $year[$row['tcaryear.carid']][] = array(
        "id"   => $row['tcaryear.yearid'], 
        "val"  => $row['tyear.year']
    );
    Code:
    // $row
    array(3) {
      ["yearid"] =>  string(1) "1"
      ["year"]   =>  string(4) "2000"
      ["carid"]  =>  string(1) "3"
    }
    ahhhhhh... i get it... thanks for help me dude.. finally i can continue my own project.. thank you very muchh dude..


 
Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •