无法在网站上正确显示数组

What I'm trying to do is make a search function for a list of a lot of products. The way the products work is that each product has a product_parent and a product_index the product_parent saves information about the product itself, and product_index saves the "sku" for the products , and when calling for all the procuts I use this code:

<script>
$(function() {
    var availableTags = ['DISCOUNT;;Discount',
        <?php   
                $get_con2 = mysql_query("SELECT * FROM `product_parents`");
                    $conarr2 = array();
                    while($con2 = mysql_fetch_array($get_con2)){
                        array_push($conarr2,$con2['id']);
                    }
                $get_con = mysql_query("SELECT * FROM `product_childs` WHERE `parent_id` IN (".implode(',',$conarr2).")");
                    $conarr = array();
                    while($con = mysql_fetch_array($get_con)){
                        array_push($conarr,$con['index_id']);
                    }
                    $showall = "WHERE `id` IN (".implode(",",$conarr).")";              

                $get_prods = mysql_query("SELECT * FROM `product_index`".$showall);
                $get_brand = mysql_query("SELECT product_parents.supplier, suppliers.id, suppliers.name FROM product_parents WHERE LEFT JOIN suppliers ON suppliers.id=product_parents.supplier");
                $get_prodname = mysql_query("SELECT product_parents.name FROM product_parents");
                $js = "";
                while($prods = mysql_fetch_array($get_prods)){
                    $prodbrand = mysql_fetch_array($get_brand);
                    $prodname = mysql_fetch_array($get_prodname);
                    /* $js .= "'". addslashes($prodbrand['name'])."". addslashes($prodname['name'])." (".indexStock($prods['id'])." on stock);;".addslashes($prods['sku'])."',"; */
                    /* $js .= "'".addslashes($prods['sku']).";; ". addslashes($prods['name'])." (".indexStock($prods['id'])." on stock)',"; */

                    $js .= "'".addslashes($prodbrand['name'])."',";
                    /* $js .= "'".addslashes($prodbrand['name'])." ".addslashes($prodname['name']).";; ". addslashes($prods['name'])." (".indexStock($prods['id'])." on stock)',"; */
                } echo substr($js,0,-1);
        ?>
    ];
    $( "#add_row_sku" ).autocomplete({
        source: availableTags
    });

});
</script>

and it's showing a bunch of results, but not all of them, however when I run the query in phpmyadmin it results every result I am trying to have it show. also, when I use:

/* $js .= "'".addslashes($prods['sku']).";; ". addslashes($prods['name'])." (".indexStock($prods['id'])." on stock)',"; */

it shows things just fine, can anyone see what I'm doing wrong here? I've been stuck for hours. also if you are willing to help but don't quite understand what I'm asking, I'll be happy to add you on skype or whatever so you can further assist me and that would be greatly appreciated!

Try this out. You can make your life easier by using json_encode to create the javascript. Build out the array in PHP and it handles any addslashes or encoding. I had to rename some of the variables as it made it hard to read. $rs is result set, $row is well table row. I prefer the $array[] syntax vs .push

<?php
  $availableTags = array('DISCOUNT;;Discount');

  // Get product parents and their supplier
  $sql = "SELECT product_parents.id, product_parents.name as parent_name, suppliers.name as supplier_name FROM `product_parents` LEFT JOIN suppliers ON suppliers.id=product_parents.supplier";
  $rs = mysql_query($sql);
  $parents = array();
  while($row = mysql_fetch_array($rs)){
    $parents[$row['id']] = $row;
  }

  // Get all product childs whatever that means
  $sql = "SELECT index_id, parent_id FROM `product_childs` WHERE `parent_id` IN (" . implode(',', array_keys($parents)). ")";
  $rs = mysql_query($sql);
  $childs = array();
  while($row = mysql_fetch_array($rs)) {
    $childs[$row['index_id']] = $row['parent_id'];
  }

  // Get all the products
  $sql = "SELECT * FROM `product_index` WHERE `id` IN (" . implode(",", array_keys($childs)) .")";
  $rs = mysql_query($sql);

  while($prods = mysql_fetch_array($rs)) {
    $availableTags[] = $prods['name'];
    $availableTags[] = $prods['sku'];
    $parentId = $childs[$prods['id']];
    $brand = $parents[$parentId]['supplier_name'];
    $parentName = $parents[$parentId]['parent_name'];
    $availableTags[] = $brand;
  }

?>
<script>
  $(function() {
    var availableTags = <?php echo json_encode($availableTags); ?>
    $( "#add_row_sku" ).autocomplete({
      source: availableTags
    });

  });
</script>